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.
-
#proc ⇒ Object
readonly
Returns the value of attribute proc.
Instance Method Summary collapse
- #==(a2) ⇒ Object
- #fire(match, engine = nil) ⇒ Object
-
#initialize(&block) ⇒ Action
constructor
A new instance of Action.
Constructor Details
#initialize(&block) ⇒ Action
Returns a new instance of Action.
28 29 30 31 32 |
# File 'lib/core/engine.rb', line 28 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 |
#proc ⇒ Object (readonly)
Returns the value of attribute proc.
26 27 28 |
# File 'lib/core/engine.rb', line 26 def proc @proc end |
Instance Method Details
#==(a2) ⇒ Object
42 43 44 |
# File 'lib/core/engine.rb', line 42 def ==(a2) return @name == a2.name end |
#fire(match, engine = nil) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/core/engine.rb', line 34 def fire(match, engine=nil) if @proc.arity == 2 @proc.call(match, engine) else @proc.call(match) end end |