-
-
Save lastk/2407666 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PostCommitmentContext | |
def initialize(params) | |
@params = params | |
end | |
def save | |
@post = Post.new(@params) | |
if @post.save | |
# @post é ActiveRecord, então não há o que extender mesmo porque ActiveRecord já está encruado | |
Twitter.send_notification({login: "login",pass:"password"},@post.title) | |
end | |
end | |
end | |
class PostsController < ActionController::Base | |
def create | |
@context = PostCommitmentContext.new(params[:posts]) | |
if @context.save | |
# redirect | |
# ... | |
end | |
end | |
end | |
class Twitter | |
def self.send_notification(user,text) | |
twitter = login(user.login,user.password) #dont mind about the names, ok? | |
twitter.send(text) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment