Class: Ruleby::Core::TypeNode
- Inherits:
-
HashedNode
- Object
- Printable
- Node
- ParentNode
- AtomNode
- HashedNode
- Ruleby::Core::TypeNode
- Defined in:
- lib/core/nodes.rb
Overview
This node class is used to match the type of a fact. In this case the type is matched exactly (ignoring inheritance).
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from AtomNode
Attributes inherited from ParentNode
Attributes inherited from Printable
Instance Method Summary collapse
- #assert(fact) ⇒ Object
- #hash_by(atom) ⇒ Object
- #propagate(propagation_method, fact, out_nodes = @out_nodes) ⇒ Object
- #retract(fact) ⇒ Object
Methods inherited from HashedNode
Methods inherited from AtomNode
#==, #initialize, #shareable?, #to_s
Methods inherited from ParentNode
#add_out_node, #initialize, #modify, #propagate_assert, #propagate_modify, #propagate_retract
Methods inherited from Node
Methods inherited from Printable
Constructor Details
This class inherits a constructor from Ruleby::Core::HashedNode
Instance Method Details
#assert(fact) ⇒ Object
430 431 432 433 434 435 436 437 438 439 440 |
# File 'lib/core/nodes.rb', line 430 def assert(fact) k = fact.object.send(@atom.slot) # TODO we should create the Assertion object here, not in propogate propagate_assert fact, (@values[k] ? @values[k] : {}) rescue NoMethodError => e @bucket.add_error Error.new(:no_method, :warn, { :object => fact.object.to_s, :method => e.name, :message => e. }) end |
#hash_by(atom) ⇒ Object
422 423 424 |
# File 'lib/core/nodes.rb', line 422 def hash_by(atom) atom.template.clazz end |
#propagate(propagation_method, fact, out_nodes = @out_nodes) ⇒ Object
442 443 444 445 446 447 448 449 450 |
# File 'lib/core/nodes.rb', line 442 def propagate(propagation_method, fact, out_nodes=@out_nodes) out_nodes.each do |out_node, paths| begin out_node.send(propagation_method, Assertion.new(fact, paths)) rescue => e @bucket.add_error Error.new(:unknown, :error, {:type => e.class, :message => e.}) end end end |
#retract(fact) ⇒ Object
426 427 428 |
# File 'lib/core/nodes.rb', line 426 def retract(fact) propagate_retract fact, @values.values.inject({}){|p,c| p.merge(c)} #(@values[k] ? @values[k] : {}) end |