Class: SardonyxRing::Handlers::ActionHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/sardonyx_ring/handlers/action_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(action_id, callback) ⇒ ActionHandler

Returns a new instance of ActionHandler.



6
7
8
9
# File 'lib/sardonyx_ring/handlers/action_handler.rb', line 6

def initialize(action_id, callback)
  @action_id = action_id
  @callback = callback
end

Instance Attribute Details

#action_idObject (readonly)

Returns the value of attribute action_id.



11
12
13
# File 'lib/sardonyx_ring/handlers/action_handler.rb', line 11

def action_id
  @action_id
end

Instance Method Details

#match?(action_event) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/sardonyx_ring/handlers/action_handler.rb', line 18

def match?(action_event)
  @action_id == action_event.current_action.action_id
end

#run(app, action_event) ⇒ Object



13
14
15
16
# File 'lib/sardonyx_ring/handlers/action_handler.rb', line 13

def run(app, action_event)
  args = [action_event].slice(0, @callback.arity)
  @callback.bind(app).call(*args)
end