Class: Wonkavision::EventBinding
- Inherits:
-
Object
- Object
- Wonkavision::EventBinding
- Defined in:
- lib/wonkavision/event_binding.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#events ⇒ Object
readonly
Returns the value of attribute events.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(name, handler, *args) ⇒ EventBinding
constructor
A new instance of EventBinding.
- #subscribe_to_events(&block) ⇒ Object
Constructor Details
#initialize(name, handler, *args) ⇒ EventBinding
Returns a new instance of EventBinding.
6 7 8 9 10 11 12 13 14 |
# File 'lib/wonkavision/event_binding.rb', line 6 def initialize(name,handler,*args) args.flatten! @options = args. @handler = handler @name = name @events = [] args = [@name] if args.blank? || args.flatten.blank? @events = args.flatten.map{|evt_name|@handler.event_path(evt_name)} end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
4 5 6 |
# File 'lib/wonkavision/event_binding.rb', line 4 def events @events end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/wonkavision/event_binding.rb', line 4 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/wonkavision/event_binding.rb', line 4 def @options end |
Instance Method Details
#subscribe_to_events(&block) ⇒ Object
16 17 18 19 20 |
# File 'lib/wonkavision/event_binding.rb', line 16 def subscribe_to_events(&block) @events.each do |event| Wonkavision.event_coordinator.subscribe(event,&block) end end |