Module: XamplExample::ThingsAsChild

Included in:
Thing
Defined in:
lib/xamplr/handwritten/example.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#things_childObject

Returns the value of attribute things_child.



7
8
9
# File 'lib/xamplr/handwritten/example.rb', line 7

def things_child
  @things_child
end

Instance Method Details

#add_things(things) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/xamplr/handwritten/example.rb', line 13

def add_things(things)
  @children << things
  @things_child << things
  things.add_parent(self)
  changed
  return things
end

#init_things_as_childObject



9
10
11
# File 'lib/xamplr/handwritten/example.rb', line 9

def init_things_as_child
  @things_child = []
end

#new_things {|things| ... } ⇒ Object

Yields:

  • (things)


21
22
23
24
25
# File 'lib/xamplr/handwritten/example.rb', line 21

def new_things
  things = Things.new
  yield(things) if block_given?
  return add_things(things)
end

#remove_things(things) ⇒ Object



27
28
29
30
# File 'lib/xamplr/handwritten/example.rb', line 27

def remove_things(things)
  @things_child.delete(things)
  @children.delete(things)
end