This file contains hidden or 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
subscribe "task_changed" do |attributes| | |
if attributes["state"] == 'opened' | |
TaskIndex.write(attributes["id"]) | |
end | |
end |
This file contains hidden or 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
# initializer | |
ResqueBus.dispatch("app_b") do | |
subscribe "user_created" do |attributes| | |
# business logic | |
NameCount.find_or_create_by_name(attributes["last_name"]).increment! | |
end | |
end |
This file contains hidden or 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
# business logic | |
ResqueBus.publish("user_created", "id" => 42, "first_name" => "John", "last_name" => "Smith") | |
# or do it later | |
ResqueBus.publish_at(1.hour.from_now, "user_created", "id" => 42, "first_name" => "John", "last_name" => "Smith") |
This file contains hidden or 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 Profile::ContentSubscriber | |
include ResqueBus::Subscriber | |
subscribe :post_rated | |
def post_rated(attributes) | |
total = Profile::Rate.where(author_id: attributes['author_id']).count | |
sum = Profile::Rate.where(author_id: attributes['author_id']).sum(:rating) | |
profile = Profile::Document.find_by(user_id: attributes['post_author_id']) |
This file contains hidden or 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 Profile::ContentSubscriber | |
include ResqueBus::Subscriber | |
subscribe :post_created | |
def post_created(attributes) | |
profile = Profile::Document.find_by(user_id: attributes['post_author_id']) | |
profile.post_ratings_total = attributes['total_ratings'] | |
profile.post_rating_average = attributes['new_average'] | |
profile.save! |
This file contains hidden or 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
ResqueBus.dispatch('profile') do | |
subscribe 'post_rated' do |attributes| | |
profile = Profile::Document.find_by(user_id: attributes['author_id']) | |
profile.post_ratings_total = attributes['total_ratings'] | |
profile.post_rating_average = attributes['new_average'] | |
profile.save! | |
end | |
end |
This file contains hidden or 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
$ ENGINE_BOOT=am bundle exec rails c | |
=> will boot the account and marketing engines - but not content, admin, etc. | |
$ ENGINE_BOOT=-m bundle exec rails c | |
=> will boot all engines except marketing |
This file contains hidden or 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
# Gemfile | |
gemspec path: "apps/shared" | |
BootInquirer.each_active_app do |app| | |
gemspec path: "apps/#{app.gem_name}" | |
end |
This file contains hidden or 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
APPS = { | |
'a' => 'account', | |
'c' => 'content', | |
'm' => 'marketing', | |
'z' => 'admin' | |
} |
This file contains hidden or 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
describe Content::Post do | |
fixtures :users | |
it "should be associated with a user" do | |
user = fixture(:users, :willy, Content) | |
post = Content::Post.new(content: "words") | |
post.user = user | |
post.save.should == true | |
user.posts.count.should == 1 | |
end |