9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/juniter/has_children.rb', line 9
def child(name, as: nil, array: false, map: nil)
child_types << name
child_aliases[name] = as unless as.nil?
child_processors[name] = map || ->(node) { node.text }
array_children << name if array
define_method :"#{name}" do
instance_variable_set(:"@_#{name}", array ? [] : nil ) unless instance_variable_defined?(:"@_#{name}")
instance_variable_get(:"@_#{name}")
end
define_method :"#{name}=" do |value|
instance_variable_set :"@_#{name}", value
end
end
|