Class: Wongi::Engine::DSL::Clause::Generic
- Inherits:
-
Object
- Object
- Wongi::Engine::DSL::Clause::Generic
- Defined in:
- lib/wongi-engine/dsl/clause/generic.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#name ⇒ Object
Returns the value of attribute name.
-
#rule ⇒ Object
Returns the value of attribute rule.
Instance Method Summary collapse
- #compile(*args) ⇒ Object
- #execute(*args) ⇒ Object
- #import_into(rete) ⇒ Object
-
#initialize(*args, &block) ⇒ Generic
constructor
A new instance of Generic.
Constructor Details
#initialize(*args, &block) ⇒ Generic
Returns a new instance of Generic.
6 7 8 9 |
# File 'lib/wongi-engine/dsl/clause/generic.rb', line 6 def initialize(*args, &block) @args = args @block = block end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
4 5 6 |
# File 'lib/wongi-engine/dsl/clause/generic.rb', line 4 def action @action end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/wongi-engine/dsl/clause/generic.rb', line 4 def name @name end |
#rule ⇒ Object
Returns the value of attribute rule.
4 5 6 |
# File 'lib/wongi-engine/dsl/clause/generic.rb', line 4 def rule @rule end |
Instance Method Details
#compile(*args) ⇒ Object
27 28 29 |
# File 'lib/wongi-engine/dsl/clause/generic.rb', line 27 def compile(*args) action.call(*args) end |
#execute(*args) ⇒ Object
31 32 33 |
# File 'lib/wongi-engine/dsl/clause/generic.rb', line 31 def execute(*args) action.call(*args) end |
#import_into(rete) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/wongi-engine/dsl/clause/generic.rb', line 11 def import_into(rete) if action.respond_to? :call self else action.new(*@args, &@block).tap do |a| a.name = name if a.respond_to? :name= a.rule = rule if a.respond_to? :rule= a.rete = rete if a.respond_to? :rete= end end rescue StandardError => e e1 = StandardError.new "error defining clause #{name} handled by #{action}: #{e}" e1.set_backtrace e.backtrace raise e1 end |