Class: Rulz::Action

Inherits:
Object
  • Object
show all
Defined in:
lib/rulz/action.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, klass, proc) ⇒ Action

Returns a new instance of Action.



5
6
7
8
9
10
11
12
# File 'lib/rulz/action.rb', line 5

def initialize(name, klass, proc)
  @name = name
  @proc = proc
  klass.instance_exec self do |action|
    @rulz_actions ||= []
    @rulz_actions << action
  end
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/rulz/action.rb', line 3

def name
  @name
end

#procObject

Returns the value of attribute proc.



3
4
5
# File 'lib/rulz/action.rb', line 3

def proc
  @proc
end

Class Method Details

.find(klass, name) ⇒ Object



14
15
16
# File 'lib/rulz/action.rb', line 14

def self.find(klass, name)
  klass.instance_variable_get(:@rulz_actions).find {|c| c.name == name }
end