Sha256: 6b5e4446e429185c7cf8a1a18a187b65d043992e7d080900cfe1b45ee27d2a78

Contents?: true

Size: 715 Bytes

Versions: 8

Compression:

Stored size: 715 Bytes

Contents

module Apotomo
  class InvokeEventHandler < EventHandler
    attr_accessor :widget_id, :state
    
    def initialize(opts={})
      @widget_id  = opts.delete(:widget_id)
      @state      = opts.delete(:state)
    end
    
    def process_event(event)
      target = event.source.root.find_by_path(widget_id) ### DISCUSS: widget_id or widget_selector?
      
      #::Rails.logger.debug "EventHandler: invoking #{target.name}##{state}"
      ### DISCUSS: let target access event?
      ###   pass additional opts to #invoke?
      ### DISCUSS: pass block here?
      target.opts[:event] = event
      
      target.invoke(state)
    end
    
    def to_s; "InvokeEventHandler:#{widget_id}##{state}"; end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
apotomo-1.0.1 lib/apotomo/invoke_event_handler.rb
apotomo-1.0.0 lib/apotomo/invoke_event_handler.rb
apotomo-1.0.0.beta2 lib/apotomo/invoke_event_handler.rb
apotomo-1.0.0.beta1 lib/apotomo/invoke_event_handler.rb
apotomo-0.1.4 lib/apotomo/invoke_event_handler.rb
apotomo-0.1.3 lib/apotomo/invoke_event_handler.rb
apotomo-0.1.2 lib/apotomo/invoke_event_handler.rb
apotomo-0.1.1 lib/apotomo/invoke_event_handler.rb