Module: XamplExample::StuffAsChild
- Included in:
- Thing
- Defined in:
- lib/xamplr/handwritten/example.rb,
lib/xamplr/handwritten/hand-example.rb
Instance Attribute Summary collapse
-
#stuff_child ⇒ Object
Returns the value of attribute stuff_child.
Instance Method Summary collapse
- #add_stuff(stuff) ⇒ Object
- #init_stuff_as_child ⇒ Object
- #new_stuff {|stuff| ... } ⇒ Object
- #remove_stuff(stuff) ⇒ Object
Instance Attribute Details
#stuff_child ⇒ Object
Returns the value of attribute stuff_child.
191 192 193 |
# File 'lib/xamplr/handwritten/example.rb', line 191 def stuff_child @stuff_child end |
Instance Method Details
#add_stuff(stuff) ⇒ Object
197 198 199 200 201 202 203 |
# File 'lib/xamplr/handwritten/example.rb', line 197 def add_stuff(stuff) @children << stuff @stuff_child << stuff stuff.add_parent(self) changed return stuff end |
#init_stuff_as_child ⇒ Object
193 194 195 |
# File 'lib/xamplr/handwritten/example.rb', line 193 def init_stuff_as_child @stuff_child = [] end |
#new_stuff {|stuff| ... } ⇒ Object
205 206 207 208 209 |
# File 'lib/xamplr/handwritten/example.rb', line 205 def new_stuff stuff = Stuff.new yield(stuff) if block_given? return add_stuff(stuff) end |
#remove_stuff(stuff) ⇒ Object
211 212 213 214 |
# File 'lib/xamplr/handwritten/example.rb', line 211 def remove_stuff(stuff) @stuff_child.delete(stuff) @children.delete(stuff) end |