Skip to content

Instantly share code, notes, and snippets.

@claymccoy
Created August 18, 2008 15:56
Show Gist options
  • Save claymccoy/5997 to your computer and use it in GitHub Desktop.
Save claymccoy/5997 to your computer and use it in GitHub Desktop.
class TreeNode
def method_missing(methodname, *args, &block)
child = self.children().find { |child| methodname.to_s == child.name }
if child.nil?
child = TreeNode.new(methodname.to_s)
self.add_child(child)
end
child.instance_eval(&block) if block_given?
child
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment