Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Wisper::EnlightenedPublisher
- extend ActiveSupport::Concern
- included do
- include Wisper::Publisher
- prepend PrependedMethods
- end
- def subscribe_to_listeners
- self.class.wisper_listeners.each do |listener|
- subscribe(listener.constantize.new)
- end
- end
- module PrependedMethods
- def initialize(*args, &block) # ack what is the right signature here, I don't even know.
- super
- subscribe_to_listeners
- end
- end
- module ClassMethods
- def subscriber(klass)
- wisper_subscriptions << klass
- end
- def wisper_subscriptions
- @wisper_subscriptions ||= []
- end
- end
- end
- class MyInteraction
- include Wisper::EnlightenedPublisher
- subscriber "AnalyticsListener"
- def initialize(user)
- @user = user
- end
- def run
- broadcast :something
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement