Class: SardonyxRing::Handlers::ActionHandler
- Inherits:
-
Object
- Object
- SardonyxRing::Handlers::ActionHandler
- Defined in:
- lib/sardonyx_ring/handlers/action_handler.rb
Instance Attribute Summary collapse
-
#action_id ⇒ Object
readonly
Returns the value of attribute action_id.
Instance Method Summary collapse
-
#initialize(action_id, callback) ⇒ ActionHandler
constructor
A new instance of ActionHandler.
- #match?(action_event) ⇒ Boolean
- #run(app, action_event) ⇒ Object
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_id ⇒ Object (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
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 |