Class: Ruleby::Core::Action

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#matchesObject (readonly)

Returns the value of attribute matches.



25
26
27
# File 'lib/core/engine.rb', line 25

def matches
  @matches
end

#nameObject

Returns the value of attribute name.



24
25
26
# File 'lib/core/engine.rb', line 24

def name
  @name
end

#priorityObject

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