class DataMapper::DescendantSet
Public Class Methods
new(descendants = [])
click to toggle source
Initialize a DescendantSet instance
@param [#to_ary] descendants
initialize with the descendants
@api private
# File lib/dm-core/support/descendant_set.rb, line 11 def initialize(descendants = []) @descendants = SubjectSet.new(descendants) end
Public Instance Methods
<<(descendant)
click to toggle source
Add a descendant
@param [Module] descendant
@return [DescendantSet]
self
@api private
# File lib/dm-core/support/descendant_set.rb, line 33 def <<(descendant) @descendants << descendant self end
clear()
click to toggle source
Removes all entries and returns self
@return [DescendantSet] self
@api private
# File lib/dm-core/support/descendant_set.rb, line 84 def clear @descendants.clear end
delete(descendant)
click to toggle source
Remove a descendant
Also removes from all descendants
@param [Module] descendant
@return [DescendantSet]
self
@api private
# File lib/dm-core/support/descendant_set.rb, line 48 def delete(descendant) @descendants.delete(descendant) each { |d| d.descendants.delete(descendant) } end
each() { |descendant| ... }
click to toggle source
Iterate over each descendant
@yield [descendant] @yieldparam [Module] descendant
@return [DescendantSet]
self
@api private
# File lib/dm-core/support/descendant_set.rb, line 62 def each @descendants.each do |descendant| yield descendant descendant.descendants.each { |dd| yield dd } end self end
empty?()
click to toggle source
Test if there are any descendants
@return [Boolean]
@api private
# File lib/dm-core/support/descendant_set.rb, line 75 def empty? @descendants.empty? end
initialize_copy(original)
click to toggle source
Copy a DescendantSet instance
@param [DescendantSet] original
the original descendants
@api private
# File lib/dm-core/support/descendant_set.rb, line 21 def initialize_copy(original) @descendants = @descendants.dup end