Created
August 17, 2011 22:02
-
-
Save anewusername1/1152758 to your computer and use it in GitHub Desktop.
subscriber code example
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
| EM.schedule do | |
| user_subscription = Subscriptions::User.new | |
| Ragnar.exchange(:topic, 'events') do |x| | |
| x.queue_prefix = :service_name | |
| x.subscribe('user.delete', &user_subscription.method(:user_delete)) | |
| x.subscribe('user.login', &user_subscription.method(:user_login)) | |
| 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
| module Subscriptions | |
| class User | |
| def user_delete(headers, payload) | |
| begin | |
| # do something here | |
| rescue | |
| # handle the errors | |
| end | |
| end | |
| def user_login(headers, payload) | |
| begin | |
| # do something here | |
| rescue | |
| #handle the errors | |
| end | |
| end | |
| 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
| require 'spec_helper' | |
| describe Subscriptions::User do | |
| describe '#user_delete' do | |
| context 'no errors' do | |
| it 'checks that something happened' do | |
| # spec here | |
| end | |
| end | |
| context 'errors' do | |
| it 'checks that the right error was raised' do | |
| # spec here | |
| end | |
| end | |
| end | |
| describe '#user_login' do | |
| context 'no errors' do | |
| it 'checks that something happened' do | |
| # spec here | |
| end | |
| end | |
| context 'errors' do | |
| it 'checks that the right error was raised' do | |
| # spec here | |
| end | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment