class Wongi::Engine::ProductionNode

Attributes

compilation_context[RW]
name[RW]
tracer[RW]

Public Class Methods

new(name, parent, actions) click to toggle source
Calls superclass method Wongi::Engine::BetaNode::new
# File lib/wongi-engine/beta/production_node.rb, line 6
def initialize(name, parent, actions)
  super(parent)
  @actions = actions.each { |action| action.production = self }
  @name = name
end

Public Instance Methods

beta_activate(token) click to toggle source
# File lib/wongi-engine/beta/production_node.rb, line 12
def beta_activate(token)
  # p beta_activate: {class: self.class, object_id:, token:}
  return if tokens.find { |t| t.duplicate? token }

  overlay.add_token(token)

  @actions.each do |action|
    action.execute token if action.respond_to? :execute
  end
end
beta_deactivate(token) click to toggle source
# File lib/wongi-engine/beta/production_node.rb, line 23
def beta_deactivate(token)
  # p beta_deactivate: {class: self.class, object_id:, token:}

  # we should remove before the actions because otherwise the longer rule chains (like the infinite neg-gen cycle) don't work as expected
  overlay.remove_token(token)

  @actions.each do |action|
    action.deexecute token if action.respond_to? :deexecute
  end
end