Default the body to an empty string if its nil

This commit is contained in:
R. Tyler Croy 2012-03-24 23:39:06 -07:00
parent 84e1174067
commit aebed91700
3 changed files with 71 additions and 71 deletions

View File

@ -1,15 +1,28 @@
smalltalk.addPackage('GitHub', {});
smalltalk.addClass('User', smalltalk.Object, ['raw', 'fullName', 'login', 'imageUrl', 'userId', 'bio', 'email', 'profileUrl'], 'GitHub');
smalltalk.addClass('Comment', smalltalk.Object, ['raw', 'login', 'body', 'created_at'], 'GitHub');
smalltalk.addMethod(
unescape('_withData_'),
smalltalk.method({
selector: unescape('withData%3A'),
fn: function (aDict){
var self=this;
(self['@login']=smalltalk.send(aDict, "_at_", ["login"]));
(self['@raw']=aDict);
(self['@body']=smalltalk.send(aDict, "_at_", ["body"]));
(self['@login']=smalltalk.send(smalltalk.send(aDict, "_at_", ["user"]), "_at_", ["login"]));
return self;}
}),
smalltalk.User);
smalltalk.Comment);
smalltalk.addMethod(
unescape('_body'),
smalltalk.method({
selector: unescape('body'),
fn: function (){
var self=this;
return self['@body'];
return self;}
}),
smalltalk.Comment);
smalltalk.addMethod(
unescape('_login'),
@ -20,7 +33,7 @@ var self=this;
return self['@login'];
return self;}
}),
smalltalk.User);
smalltalk.Comment);
@ -76,30 +89,17 @@ smalltalk.APIBase);
smalltalk.addClass('Comment', smalltalk.Object, ['raw', 'login', 'body', 'created_at'], 'GitHub');
smalltalk.addClass('User', smalltalk.Object, ['raw', 'fullName', 'login', 'imageUrl', 'userId', 'bio', 'email', 'profileUrl'], 'GitHub');
smalltalk.addMethod(
unescape('_withData_'),
smalltalk.method({
selector: unescape('withData%3A'),
fn: function (aDict){
var self=this;
(self['@raw']=aDict);
(self['@body']=smalltalk.send(aDict, "_at_", ["body"]));
(self['@login']=smalltalk.send(smalltalk.send(aDict, "_at_", ["user"]), "_at_", ["login"]));
(self['@login']=smalltalk.send(aDict, "_at_", ["login"]));
return self;}
}),
smalltalk.Comment);
smalltalk.addMethod(
unescape('_body'),
smalltalk.method({
selector: unescape('body'),
fn: function (){
var self=this;
return self['@body'];
return self;}
}),
smalltalk.Comment);
smalltalk.User);
smalltalk.addMethod(
unescape('_login'),
@ -110,7 +110,7 @@ var self=this;
return self['@login'];
return self;}
}),
smalltalk.Comment);
smalltalk.User);
@ -243,7 +243,7 @@ smalltalk.method({
selector: unescape('body'),
fn: function (){
var self=this;
return self['@body'];
return (($receiver = self['@body']) == nil || $receiver == undefined) ? (function(){return (self['@body']="");})() : $receiver;
return self;}
}),
smalltalk.Issue);

View File

@ -1,5 +1,5 @@
smalltalk.addPackage('GitHub', {});
smalltalk.addClass('User', smalltalk.Object, ['raw', 'fullName', 'login', 'imageUrl', 'userId', 'bio', 'email', 'profileUrl'], 'GitHub');
smalltalk.addClass('Comment', smalltalk.Object, ['raw', 'login', 'body', 'created_at'], 'GitHub');
smalltalk.addMethod(
unescape('_withData_'),
smalltalk.method({
@ -7,14 +7,32 @@ selector: unescape('withData%3A'),
category: 'initializers',
fn: function (aDict){
var self=this;
(self['@login']=smalltalk.send(aDict, "_at_", ["login"]));
(self['@raw']=aDict);
(self['@body']=smalltalk.send(aDict, "_at_", ["body"]));
(self['@login']=smalltalk.send(smalltalk.send(aDict, "_at_", ["user"]), "_at_", ["login"]));
return self;},
args: ["aDict"],
source: unescape('withData%3A%20aDict%0A%09%22%20Seed%20the%20User%20object%20with%20data%20acquired%20from%20the%20API%22%0A%09login%20%3A%3D%20aDict%20at%3A%20%27login%27.'),
source: unescape('withData%3A%20aDict%0A%09raw%20%3A%3D%20aDict.%0A%09body%20%3A%3D%20aDict%20at%3A%20%27body%27.%0A%09login%20%3A%3D%20%28aDict%20at%3A%20%27user%27%29%20at%3A%20%27login%27.'),
messageSends: ["at:"],
referencedClasses: []
}),
smalltalk.User);
smalltalk.Comment);
smalltalk.addMethod(
unescape('_body'),
smalltalk.method({
selector: unescape('body'),
category: 'accessors',
fn: function (){
var self=this;
return self['@body'];
return self;},
args: [],
source: unescape('body%0A%09%5E%20body.'),
messageSends: [],
referencedClasses: []
}),
smalltalk.Comment);
smalltalk.addMethod(
unescape('_login'),
@ -30,7 +48,7 @@ source: unescape('login%0A%09%5E%20login.'),
messageSends: [],
referencedClasses: []
}),
smalltalk.User);
smalltalk.Comment);
@ -106,7 +124,7 @@ smalltalk.APIBase);
smalltalk.addClass('Comment', smalltalk.Object, ['raw', 'login', 'body', 'created_at'], 'GitHub');
smalltalk.addClass('User', smalltalk.Object, ['raw', 'fullName', 'login', 'imageUrl', 'userId', 'bio', 'email', 'profileUrl'], 'GitHub');
smalltalk.addMethod(
unescape('_withData_'),
smalltalk.method({
@ -114,32 +132,14 @@ selector: unescape('withData%3A'),
category: 'initializers',
fn: function (aDict){
var self=this;
(self['@raw']=aDict);
(self['@body']=smalltalk.send(aDict, "_at_", ["body"]));
(self['@login']=smalltalk.send(smalltalk.send(aDict, "_at_", ["user"]), "_at_", ["login"]));
(self['@login']=smalltalk.send(aDict, "_at_", ["login"]));
return self;},
args: ["aDict"],
source: unescape('withData%3A%20aDict%0A%09raw%20%3A%3D%20aDict.%0A%09body%20%3A%3D%20aDict%20at%3A%20%27body%27.%0A%09login%20%3A%3D%20%28aDict%20at%3A%20%27user%27%29%20at%3A%20%27login%27.'),
source: unescape('withData%3A%20aDict%0A%09%22%20Seed%20the%20User%20object%20with%20data%20acquired%20from%20the%20API%22%0A%09login%20%3A%3D%20aDict%20at%3A%20%27login%27.'),
messageSends: ["at:"],
referencedClasses: []
}),
smalltalk.Comment);
smalltalk.addMethod(
unescape('_body'),
smalltalk.method({
selector: unescape('body'),
category: 'accessors',
fn: function (){
var self=this;
return self['@body'];
return self;},
args: [],
source: unescape('body%0A%09%5E%20body.'),
messageSends: [],
referencedClasses: []
}),
smalltalk.Comment);
smalltalk.User);
smalltalk.addMethod(
unescape('_login'),
@ -155,7 +155,7 @@ source: unescape('login%0A%09%5E%20login.'),
messageSends: [],
referencedClasses: []
}),
smalltalk.Comment);
smalltalk.User);
@ -339,11 +339,11 @@ selector: unescape('body'),
category: 'accessors',
fn: function (){
var self=this;
return self['@body'];
return (($receiver = self['@body']) == nil || $receiver == undefined) ? (function(){return (self['@body']="");})() : $receiver;
return self;},
args: [],
source: unescape('body%0A%09%5E%20body.'),
messageSends: [],
source: unescape('body%0A%09%5E%20body%20ifNil%3A%20%5B%20body%20%3A%3D%20%27%27%20%5D.'),
messageSends: ["ifNil:"],
referencedClasses: []
}),
smalltalk.Issue);

View File

@ -1,19 +1,24 @@
Smalltalk current createPackage: 'GitHub' properties: #{}!
Object subclass: #User
instanceVariableNames: 'raw fullName login imageUrl userId bio email profileUrl'
Object subclass: #Comment
instanceVariableNames: 'raw login body created_at'
category: 'GitHub'!
!User methodsFor: 'accessors'!
!Comment methodsFor: 'accessors'!
body
^ body.
!
login
^ login.
! !
!User methodsFor: 'initializers'!
!Comment methodsFor: 'initializers'!
withData: aDict
" Seed the User object with data acquired from the API"
login := aDict at: 'login'.
raw := aDict.
body := aDict at: 'body'.
login := (aDict at: 'user') at: 'login'.
! !
Object subclass: #APIBase
@ -46,26 +51,21 @@ apiUrlFor: apiString
^ url.
! !
Object subclass: #Comment
instanceVariableNames: 'raw login body created_at'
Object subclass: #User
instanceVariableNames: 'raw fullName login imageUrl userId bio email profileUrl'
category: 'GitHub'!
!Comment methodsFor: 'accessors'!
body
^ body.
!
!User methodsFor: 'accessors'!
login
^ login.
! !
!Comment methodsFor: 'initializers'!
!User methodsFor: 'initializers'!
withData: aDict
raw := aDict.
body := aDict at: 'body'.
login := (aDict at: 'user') at: 'login'.
" Seed the User object with data acquired from the API"
login := aDict at: 'login'.
! !
APIBase subclass: #Issue
@ -111,7 +111,7 @@ url
!
body
^ body.
^ body ifNil: [ body := '' ].
! !
!Issue methodsFor: 'actions'!