Class: Ruleby::Core::ReferenceNode
- Defined in:
- lib/core/nodes.rb
Overview
This node class is used to match properties of one with the properties of any other already matched fact. It differs from the other AtomNodes because it does not perform any inline matching. The match method is only invoked by the two input node.
Instance Attribute Summary
Attributes inherited from AtomNode
Attributes inherited from ParentNode
Attributes inherited from Printable
Instance Method Summary collapse
Methods inherited from AtomNode
#==, #initialize, #shareable?, #to_s
Methods inherited from ParentNode
#add_out_node, #assert, #initialize, #modify, #propagate, #propagate_assert, #propagate_modify, #propagate_retract, #retract
Methods inherited from Node
Methods inherited from Printable
Constructor Details
This class inherits a constructor from Ruleby::Core::AtomNode
Instance Method Details
#match(left_context, right_fact) ⇒ Object
524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 |
# File 'lib/core/nodes.rb', line 524 def match(left_context,right_fact) val = right_fact.object.send(@atom.slot) args = [val] match = left_context.match @atom.vars.each do |var| args.push match.variables[var] end begin if @atom.proc.call(*args) m = MatchResult.new(match.variables.clone, true, match.fact_hash.clone, match.recency) m.recency.push right_fact.recency m.fact_hash[@atom.tag] = right_fact.id m.variables[@atom.tag] = val return m end rescue NoMethodError => e # I'd rather push this up to a high level, but its got to happen down low @bucket.add_error Error.new(:no_method, :warn, { :object => "?", :method => e.name, :args => e.args, :message => e. }) end return MatchResult.new end |