class Wongi::Engine::DSL::Clause::Generic

Attributes

action[RW]
name[RW]
rule[RW]

Public Class Methods

new(*args, &block) click to toggle source
# File lib/wongi-engine/dsl/clause/generic.rb, line 6
def initialize(*args, &block)
  @args = args
  @block = block
end

Public Instance Methods

compile(*args) click to toggle source
# File lib/wongi-engine/dsl/clause/generic.rb, line 27
def compile(*args)
  action.call(*args)
end
execute(*args) click to toggle source
# File lib/wongi-engine/dsl/clause/generic.rb, line 31
def execute(*args)
  action.call(*args)
end
import_into(rete) click to toggle source
# 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