Method: Bulldog::Processor::ArgumentTree#add

Defined in:
lib/bulldog/processor/argument_tree.rb

#add(style, arguments, &callback) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/bulldog/processor/argument_tree.rb', line 13

def add(style, arguments, &callback)
  # Assume that if the arguments are the same for a node, the
  # callback will be identical.
  child = heads[style].children.find do |node|
    node.arguments == arguments
  end
  if child
    child.styles << style
  else
    child = Node.new([style], arguments, &callback)
    heads[style].children << child
  end
  heads[style] = child
end