Module: XamplExample::ThingsAsChild
- Included in:
- Thing
- Defined in:
- lib/xamplr/handwritten/example.rb
Instance Attribute Summary collapse
-
#things_child ⇒ Object
Returns the value of attribute things_child.
Instance Method Summary collapse
- #add_things(things) ⇒ Object
- #init_things_as_child ⇒ Object
- #new_things {|things| ... } ⇒ Object
- #remove_things(things) ⇒ Object
Instance Attribute Details
#things_child ⇒ Object
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_child ⇒ Object
9 10 11 |
# File 'lib/xamplr/handwritten/example.rb', line 9 def init_things_as_child @things_child = [] end |
#new_things {|things| ... } ⇒ Object
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 |