Class: DataMapper::Model::DescendantSet
- Inherits:
-
Object
- Object
- DataMapper::Model::DescendantSet
- Includes:
- Enumerable
- Defined in:
- lib/dm-core/model/descendant_set.rb
Instance Method Summary collapse
-
#<<(model) ⇒ DescendantSet
private
Append a model as a descendant.
-
#delete(model) ⇒ Model, NilClass
private
Remove a descendant.
-
#each {|model| ... } ⇒ DescendantSet
private
Iterate over each descendant.
-
#to_ary ⇒ Array
private
Return an Array representation of descendants.
Instance Method Details
#<<(model) ⇒ DescendantSet
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Append a model as a descendant
15 16 17 18 19 |
# File 'lib/dm-core/model/descendant_set.rb', line 15 def <<(model) @descendants << model unless @descendants.include?(model) @ancestors << model if @ancestors self end |
#delete(model) ⇒ Model, NilClass
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Remove a descendant
Also removed the descendant from the ancestors.
48 49 50 51 |
# File 'lib/dm-core/model/descendant_set.rb', line 48 def delete(model) @ancestors.delete(model) if @ancestors @descendants.delete(model) end |
#each {|model| ... } ⇒ DescendantSet
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Iterate over each descendant
32 33 34 35 |
# File 'lib/dm-core/model/descendant_set.rb', line 32 def each @descendants.each { |model| yield model } self end |
#to_ary ⇒ Array
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return an Array representation of descendants
59 60 61 |
# File 'lib/dm-core/model/descendant_set.rb', line 59 def to_ary @descendants.dup end |