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
def sell_book | |
@book = Book.find(params[:id]) | |
BookSellingService.sell_book(@book) | |
end |
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 Post < ActiveRecord::Base | |
has_many :comments | |
after_create :send_tweet | |
def send_tweet | |
twitter = Twitter.login(username, password) | |
twitter.send_tweet generate_tweet_from_subject(subject) | |
end | |
end |
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 Post < ActiveRecord::Base | |
has_many :comments | |
end | |
class TwitterNotification < ActiveRecord::Observer | |
observe :post | |
def after_create post | |
twitter = Twitter.login(username, password) | |
twitter.send_tweet generate_tweet_from_subject(post.subject) |
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 TwitterNotification < ActiveRecord::Observer | |
observe :post | |
def after_create post | |
TwitterService.send_tweet post.subject | |
end | |
end | |
class TwitterService | |
def self.send_tweet subject |
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 PostsRepository | |
def find_by_id id | |
... | |
end | |
def new_posts_of_author author | |
... | |
end | |
def save post |
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
module PostsRepository | |
def new_posts_of_author author | |
... | |
end | |
end | |
class Post | |
extend PostsRepository | |
end |
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 TwitterNotification < ActiveRecord::Observer | |
observe :post | |
def after_create post | |
TwitterService.send_tweet post.subject | |
end | |
end | |
class TwitterService | |
def self.send_tweet subject |
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 TwitterNotification < ActiveRecord::Observer | |
observe :post | |
def after_create post | |
TwitterService.send_tweet post.subject | |
end | |
end | |
class TwitterService | |
def self.send_tweet subject |
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
module PostsRepository | |
def new_posts_of_author author | |
... | |
end | |
end | |
class Post < ActiveRecord::Base | |
extend PostsRepository | |
end |
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
module PostsRepository | |
def new_posts_of_author author | |
... | |
end | |
end | |
class Post < ActiveRecord::Base | |
extend PostsRepository | |
end |