Module: A4Tools::EventGenerator
- Included in:
- AcresClient, Transporter
- Defined in:
- lib/acres_client.rb
Instance Method Summary collapse
Instance Method Details
#on(key, &callback) ⇒ Object
11 12 13 14 15 |
# File 'lib/acres_client.rb', line 11 def on(key, &callback) @callbacks ||= {} @callbacks[key] ||= [] @callbacks[key].push callback end |
#passthrough(target) ⇒ Object
25 26 27 |
# File 'lib/acres_client.rb', line 25 def passthrough(target) target.on(:all) { |trigger, value| signal(trigger, value) } end |
#signal(key, value = nil) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/acres_client.rb', line 17 def signal(key, value=nil) return if @callbacks.nil? [ key, :all ].each do |k| next unless @callbacks.has_key? k @callbacks[k].each { |callback| callback.call(key, value) } end end |