Class: Subscriber

Inherits:
Object
  • Object
show all
Defined in:
app/support/subscriber.rb

Defined Under Namespace

Classes: Event

Class Method Summary collapse

Class Method Details

.on(*events, &block) ⇒ Object



14
15
16
17
18
19
20
21
# File 'app/support/subscriber.rb', line 14

def on(*events, &block)
  instance = @instance ||= self.new
  events.each do |event|
    ActiveSupport::Notifications.subscribe( event ) do |name, start, finish, id, payload|
      instance.instance_exec(Event.new(payload), &block)
    end
  end
end