var postType = closureType(
function(self, api, initArgs) {
initArgs(function(title, body) {
self.title = title;
self.body = body;
})();
closureType.extend(api, {
getBody: function() {
return self.body;
},
getTitle: function() {
return self.title;
},
setBody: function(newBody) {
if (!newBody) {
return;
}
self.body = newBody;
api.emit('bodyChange', newBody);
},
setTitle: function(newTitle) {
if (!newTitle) {
return;
}
self.title = newTitle;
api.emit('titleChange', newTitle);
}
});
},
[commentable, EventEmitter.prototype, likable]
);
function commentable(self, api, initArgs) {
initArgs(function() {
self.comments = [];
})();
closureType.extend(api, {
addComment: function(comment) {
self.comments.push(comment);
},
getComment: function(index) {
return self.comments[index];
},
getComments: function() {
return self.comments.slice();
},
numComments: function() {
return self.comments.length;
}
});
}
function likable(self, api, initArgs) {
initArgs(function() {
self.numLikes = 0;
})();
closureType.extend(api, {
addLike: function() {
self.numLikes += 1;
},
numLikes: function() {
return self.numLikes;
}
});
}