Class: Yasm::Context::StateConfiguration::ActionHook

Inherits:
Object
  • Object
show all
Defined in:
lib/yasm/context/state_configuration/action_hook.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options={})
  @method = method
  @only = [options[:only]].flatten.compact
  @except = [options[:except]].flatten.compact
end

Instance Attribute Details

#methodObject (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

Returns:

  • (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