(Use case objects)
https://gist.github.com/2838490
class PostComment def initialize(user, entry, attributes) @user = user @entry = entry @attributes = attributes end def post @comment = @user.comments.new @comment.assign_attributes(@attributes) @comment.entry = @entry @comment.save! LanguageDetector.new(@comment).set_language SpamChecker.new(@comment).check_spam CommentMailer.new(@comment).send_mail post_to_twitter if @comment.share_on_twitter? post_to_facebook if @comment.share_on_facebook? @comment end private def post_to_twitter PostToTwitter.new(@user, @comment).post end def post_to_facebook PostToFacebook.new(@user, @comment).action(:comment) end end
There was an error while loading. Please reload this page.