Module: AirportEvents::Publisher::InstanceMethods
- Defined in:
- lib/airport_events/publisher.rb
Instance Method Summary collapse
Instance Method Details
#publish(event, *args) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/airport_events/publisher.rb', line 13 def publish(event, *args) unless subscribers[event].nil? subscribers[event].each do |blk| blk.call *args end end end |
#subscribe(event, &blk) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/airport_events/publisher.rb', line 5 def subscribe(event, &blk) if subscribers[event].nil? subscribers[event] = Array.new end subscribers[event].push blk end |
#subscribers ⇒ Object
21 22 23 |
# File 'lib/airport_events/publisher.rb', line 21 def subscribers @subscribers ||= Hash.new end |