Module: Support::Tree::ClassMethods

Defined in:
lib/support/tree.rb

Instance Method Summary collapse

Instance Method Details

#attr_children(*arguments) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/support/tree.rb', line 62

def attr_children(*arguments)
  arguments.flatten.each do |name|

    unless respond_to?(name) || respond_to?("#{name}!")
      define_method(name) do
        instance_variable_get("@#{name}") || send("#{name}!")
      end
    
      define_method("#{name}!") do
        instance_variable_set("@#{name}", find_children_by_name(name))
      end
    end
    
  end
end