Class: Gamefic::Action::Hook
- Inherits:
-
Object
- Object
- Gamefic::Action::Hook
- Defined in:
- lib/gamefic/action.rb
Overview
Hooks are blocks of code that get executed before or after an actor performs an action. A before action hook is capable of cancelling the action’s performance.
Instance Attribute Summary collapse
- #callback ⇒ Object readonly
- #verbs ⇒ Object readonly
Instance Method Summary collapse
-
#initialize(verbs, callback) ⇒ Hook
constructor
A new instance of Hook.
- #match?(input) ⇒ Boolean
Constructor Details
#initialize(verbs, callback) ⇒ Hook
Returns a new instance of Hook.
22 23 24 25 |
# File 'lib/gamefic/action.rb', line 22 def initialize verbs, callback @verbs = verbs @callback = callback end |
Instance Attribute Details
#callback ⇒ Object (readonly)
20 21 22 |
# File 'lib/gamefic/action.rb', line 20 def callback @callback end |
#verbs ⇒ Object (readonly)
17 18 19 |
# File 'lib/gamefic/action.rb', line 17 def verbs @verbs end |
Instance Method Details
#match?(input) ⇒ Boolean
27 28 29 |
# File 'lib/gamefic/action.rb', line 27 def match?(input) verbs.empty? || verbs.include?(input) end |