Class: Apotomo::InvokeEventHandler

Inherits:
EventHandler show all
Defined in:
lib/apotomo/invoke_event_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from EventHandler

#==, #call

Constructor Details

#initialize(options = {}) ⇒ InvokeEventHandler



7
8
9
10
# File 'lib/apotomo/invoke_event_handler.rb', line 7

def initialize(options={})
  @widget_id  = options.delete(:widget_id)
  @state      = options.delete(:state)
end

Instance Attribute Details

#stateObject

Returns the value of attribute state



5
6
7
# File 'lib/apotomo/invoke_event_handler.rb', line 5

def state
  @state
end

#widget_idObject

Returns the value of attribute widget_id



5
6
7
# File 'lib/apotomo/invoke_event_handler.rb', line 5

def widget_id
  @widget_id
end

Instance Method Details

#process_event(event) ⇒ Object



12
13
14
15
16
# File 'lib/apotomo/invoke_event_handler.rb', line 12

def process_event(event)
  target = event.source.root.find_by_path(widget_id) ### DISCUSS: widget_id or widget_selector?
  
  target.invoke(state, event)
end

#to_sObject



18
# File 'lib/apotomo/invoke_event_handler.rb', line 18

def to_s; "InvokeEventHandler:#{widget_id}##{state}"; end