Class: Ruleby::Core::BridgeNode

Inherits:
BaseBridgeNode show all
Defined in:
lib/core/nodes.rb

Instance Attribute Summary

Attributes inherited from ParentNode

#child_nodes

Attributes inherited from Printable

#parent_nodes

Instance Method Summary collapse

Methods inherited from BaseBridgeNode

#initialize, #retract

Methods inherited from ParentNode

#add_out_node, #initialize, #modify, #propagate, #propagate_assert, #propagate_modify, #propagate_retract, #retract

Methods inherited from Node

#initialize, #resolve

Methods inherited from Printable

#initialize, #print

Constructor Details

This class inherits a constructor from Ruleby::Core::BaseBridgeNode

Instance Method Details

#assert(assertable) ⇒ Object



589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
# File 'lib/core/nodes.rb', line 589

def assert(assertable)
  fact = assertable.fact
  mr = MatchResult.new(assertable.tags)
  mr.is_match = true
  mr.recency.push fact.recency
  @pattern.atoms.each do |atom|
    mr.fact_hash[atom.tag] = fact.id
    if atom == @pattern.head
      # TODO once we fix up TypeNode, we won't need this
      mr[atom.tag] = fact.object
    elsif !mr.key?(atom.tag) and atom.slot
      # this is a big hack for the sake of performance.  should really do whats described below
      unless atom.tag.is_a?(GeneratedTag)
        # TODO it should be possible to get rid of this, and just capture it in the Nodes above
        mr[atom.tag] = fact.object.send(atom.slot)
      end
    end
  end
  propagate_assert(MatchContext.new(fact,mr))
end