Class: Yasm::Context::StateConfiguration::ActionHook
- Inherits:
-
Object
- Object
- Yasm::Context::StateConfiguration::ActionHook
- Defined in:
- lib/yasm/context/state_configuration/action_hook.rb
Instance Attribute Summary collapse
-
#method ⇒ Object
readonly
Returns the value of attribute method.
Instance Method Summary collapse
- #applicable?(action) ⇒ Boolean
-
#initialize(method, options = {}) ⇒ ActionHook
constructor
A new instance of ActionHook.
Constructor Details
#initialize(method, options = {}) ⇒ ActionHook
Returns a new instance of ActionHook.
7 8 9 10 11 |
# File 'lib/yasm/context/state_configuration/action_hook.rb', line 7 def initialize(method, ={}) @method = method @only = [[:only]].flatten.compact @except = [[:except]].flatten.compact end |
Instance Attribute Details
#method ⇒ Object (readonly)
Returns the value of attribute method.
5 6 7 |
# File 'lib/yasm/context/state_configuration/action_hook.rb', line 5 def method @method end |
Instance Method Details
#applicable?(action) ⇒ Boolean
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/yasm/context/state_configuration/action_hook.rb', line 13 def applicable?(action) if @only.empty? and @except.empty? true elsif !@only.empty? if @only.include?(action) true else false end elsif !@except.empty? if @except.include?(action) false else true end end end |