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.
7 8 9 10 |
# File 'lib/wongi-engine/dsl/clause/generic.rb', line 7 def initialize *args, &block @args = args @block = block end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
5 6 7 |
# File 'lib/wongi-engine/dsl/clause/generic.rb', line 5 def action @action end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/wongi-engine/dsl/clause/generic.rb', line 5 def name @name end |
#rule ⇒ Object
Returns the value of attribute rule.
5 6 7 |
# File 'lib/wongi-engine/dsl/clause/generic.rb', line 5 def rule @rule end |
Instance Method Details
#compile(*args) ⇒ Object
28 29 30 |
# File 'lib/wongi-engine/dsl/clause/generic.rb', line 28 def compile *args action.call *args end |
#execute(*args) ⇒ Object
32 33 34 |
# File 'lib/wongi-engine/dsl/clause/generic.rb', line 32 def execute *args action.call *args end |
#import_into(rete) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/wongi-engine/dsl/clause/generic.rb', line 12 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 |