Module: Slatan::Ear
- Defined in:
- lib/slatan/ear.rb
Overview
class to Event Dispatching for concerns
Class Method Summary collapse
-
.hear(msg) ⇒ Object
publish to subscribers.
-
.register(concern, &block) ⇒ Object
register subscriber.
Class Method Details
.hear(msg) ⇒ Object
publish to subscribers
17 18 19 20 21 22 23 |
# File 'lib/slatan/ear.rb', line 17 def hear(msg) @concerns.each do |concern, block| if block.blank? || block.call(msg) concern.hear(msg) end end end |
.register(concern, &block) ⇒ Object
register subscriber
12 13 14 |
# File 'lib/slatan/ear.rb', line 12 def register(concern, &block) @concerns << [concern, block] end |