Module: Tree::InternalParentChildArrayImplementation

Includes:
InternalParentChildImplementation
Included in:
ArrayTree
Defined in:
lib/modular_tree/implementations.rb

Instance Method Summary collapse

Methods included from InternalParentChildImplementation

#attach, #initialize

Methods included from ChildrenProperty

#attach, #children, #detach, #each_child

Methods included from ParentProperty

#parent, #parent=

Instance Method Details

#append(where, child) ⇒ Object



256
257
258
259
# File 'lib/modular_tree/implementations.rb', line 256

def append(where, child)
  super
  child.send(:parent=, self)
end

#insert(where, child) ⇒ Object



251
252
253
254
# File 'lib/modular_tree/implementations.rb', line 251

def insert(where, child)
  super
  child.send(:parent=, self)
end

#replace(where, *children) ⇒ Object

Requires that Child classes already has defined this



262
263
264
265
266
267
268
# File 'lib/modular_tree/implementations.rb', line 262

def replace(where, *children)
  children = Array(children).flatten
  subject = super(where, children)
  subject.send(:parent=, nil)
  children.each { |child| child.send(:parent=, self) }
  subject
end