Class: Rulz::Condition
- Inherits:
-
Object
- Object
- Rulz::Condition
- Defined in:
- lib/rulz/condition.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#proc ⇒ Object
Returns the value of attribute proc.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, klass, proc) ⇒ Condition
constructor
A new instance of Condition.
Constructor Details
#initialize(name, klass, proc) ⇒ Condition
Returns a new instance of Condition.
5 6 7 8 9 10 11 12 |
# File 'lib/rulz/condition.rb', line 5 def initialize(name, klass, proc) @name = name @proc = proc klass.instance_exec self do |condition| @rulz_conditions ||= [] @rulz_conditions << condition end end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/rulz/condition.rb', line 3 def name @name end |
#proc ⇒ Object
Returns the value of attribute proc.
3 4 5 |
# File 'lib/rulz/condition.rb', line 3 def proc @proc end |
Class Method Details
.find(klass, name) ⇒ Object
14 15 16 17 18 |
# File 'lib/rulz/condition.rb', line 14 def self.find(klass, name) result = klass.instance_eval { @rulz_conditions }.find {|c| c.name == name } raise ArgumentError, "Condition '#{name}' does not exist" unless result result end |