Class: Ruleby::Core::Action
- Inherits:
-
Object
- Object
- Ruleby::Core::Action
- Defined in:
- lib/core/engine.rb
Overview
An action is a wrapper for a code block that will be executed if a rule is satisfied.
Instance Attribute Summary collapse
-
#matches ⇒ Object
readonly
Returns the value of attribute matches.
-
#name ⇒ Object
Returns the value of attribute name.
-
#priority ⇒ Object
Returns the value of attribute priority.
Instance Method Summary collapse
- #==(a2) ⇒ Object
- #fire(match) ⇒ Object
-
#initialize(&block) ⇒ Action
constructor
A new instance of Action.
Constructor Details
#initialize(&block) ⇒ Action
Returns a new instance of Action.
27 28 29 30 31 |
# File 'lib/core/engine.rb', line 27 def initialize(&block) @name = nil @proc = Proc.new(&block) if block_given? @priority = 0 end |
Instance Attribute Details
#matches ⇒ Object (readonly)
Returns the value of attribute matches.
25 26 27 |
# File 'lib/core/engine.rb', line 25 def matches @matches end |
#name ⇒ Object
Returns the value of attribute name.
24 25 26 |
# File 'lib/core/engine.rb', line 24 def name @name end |
#priority ⇒ Object
Returns the value of attribute priority.
23 24 25 |
# File 'lib/core/engine.rb', line 23 def priority @priority end |
Instance Method Details
#==(a2) ⇒ Object
37 38 39 |
# File 'lib/core/engine.rb', line 37 def ==(a2) return @name == a2.name end |
#fire(match) ⇒ Object
33 34 35 |
# File 'lib/core/engine.rb', line 33 def fire(match) @proc.call(match) end |