Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

renamed @method_name to @slot

  • Loading branch information...
commit d90b59cdcdb6a3456c8a1826ba87b9ff75c0b9dc 1 parent 09059e1
@jkutner jkutner authored
Showing with 21 additions and 21 deletions.
  1. +12 −12 lib/core/atoms.rb
  2. +9 −9 lib/core/nodes.rb
View
24 lib/core/atoms.rb
@@ -14,17 +14,17 @@ module Ruleby
module Core
class Atom
- attr_reader :tag, :proc, :method_name, :template
+ attr_reader :tag, :proc, :slot, :template
- def initialize(tag, method_name, template, &block)
+ def initialize(tag, slot, template, &block)
@tag = tag
- @method_name = method_name
+ @slot = slot
@template = template
@proc = Proc.new(&block) if block_given?
end
def to_s
- "#{self.class},#{@tag},#{@method_name},#{@template}"
+ "#{self.class},#{@tag},#{@slot},#{@template}"
end
end
@@ -41,7 +41,7 @@ def ==(atom)
def shareable?(atom)
PropertyAtom === atom &&
- @method_name == atom.method_name &&
+ @slot == atom.slot &&
@template == atom.template &&
@proc == atom.proc
end
@@ -53,7 +53,7 @@ class FunctionAtom < Atom
def initialize(tag, template, arguments, block)
@tag = tag
- @method_name = nil
+ @slot = nil
@template = template
@arguments = arguments
@proc = block
@@ -86,14 +86,14 @@ def shareable?(atom)
# So there are no references to other atoms.
class EqualsAtom < PropertyAtom
attr_reader :value
- def initialize(tag, method_name, template, value)
- super(tag,method_name,template)
+ def initialize(tag, slot, template, value)
+ super(tag,slot,template)
@value = value
end
def shareable?(atom)
EqualsAtom === atom &&
- @method_name == atom.method_name &&
+ @slot == atom.slot &&
@template == atom.template
end
end
@@ -126,8 +126,8 @@ def shareable?(atom)
class ReferenceAtom < Atom
attr_reader :vars
- def initialize(tag, method_name, vars, template, &block)
- super(tag, method_name, template, &block)
+ def initialize(tag, slot, vars, template, &block)
+ super(tag, slot, template, &block)
@vars = vars # list of referenced variable names
end
@@ -150,7 +150,7 @@ def to_s
# This is an atom that references another atom that is in the same pattern.
# Note that in a SelfReferenceAtom, the 'vars' argument must be a list of the
- # *method_names* that this atom references (not the variable names)!
+ # *slots* that this atom references (not the variable names)!
class SelfReferenceAtom < ReferenceAtom
end
View
18 lib/core/nodes.rb
@@ -378,7 +378,7 @@ def shareable?(node)
end
def to_s
- super + " - #{@atom.method_name}"
+ super + " - #{@atom.slot}"
end
end
@@ -406,7 +406,7 @@ def retract(assertable)
end
def assert(assertable)
- k = assertable.fact.object.send(@atom.method_name)
+ k = assertable.fact.object.send(@atom.slot)
# TODOwe need to do this for ALL tags if this node is shared
assertable.add_tag(@atom.tag, k)
@@ -432,7 +432,7 @@ def retract(fact)
end
def assert(fact)
- k = fact.object.send(@atom.method_name)
+ 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
@@ -468,7 +468,7 @@ def assert(fact)
class PropertyNode < AtomNode
def assert(assertable)
begin
- val = assertable.fact.object.send(@atom.method_name)
+ val = assertable.fact.object.send(@atom.slot)
assertable.add_tag(@atom.tag, val)
rescue NoMethodError => e
@bucket.add_error Error.new(:no_method, :warn, {
@@ -483,7 +483,7 @@ def assert(assertable)
rescue Exception => e
@bucket.add_error Error.new(:proc_call, :error, {
:object => assertable.fact.object.to_s,
- :method => @atom.method_name,
+ :method => @atom.slot,
:value => val.to_s,
:message => e.message
})
@@ -522,7 +522,7 @@ def assert(assertable)
# invoked by the two input node.
class ReferenceNode < AtomNode
def match(left_context,right_fact)
- val = right_fact.object.send(@atom.method_name)
+ val = right_fact.object.send(@atom.slot)
args = [val]
match = left_context.match
@atom.vars.each do |var|
@@ -558,7 +558,7 @@ def assert(assertable)
end
def match(fact)
- args = [fact.object.send(@atom.method_name)]
+ args = [fact.object.send(@atom.slot)]
@atom.vars.each do |var|
args.push fact.object.send(var)
end
@@ -596,11 +596,11 @@ def assert(assertable)
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.method_name
+ 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.method_name)
+ mr[atom.tag] = fact.object.send(atom.slot)
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.