Module: MongoMapper::Support::DescendantAppends

Included in:
Document, EmbeddedDocument
Defined in:
lib/mongo_mapper/support/descendant_appends.rb

Instance Method Summary collapse

Instance Method Details

#append_extensions(*extensions) ⇒ Object



17
18
19
20
21
22
# File 'lib/mongo_mapper/support/descendant_appends.rb', line 17

def append_extensions(*extensions)
  extra_extensions.concat(extensions)
  descendants.each do |model|
    extensions.each { |extension| model.extend(extension) }
  end
end

#append_inclusions(*inclusions) ⇒ Object



25
26
27
28
29
30
# File 'lib/mongo_mapper/support/descendant_appends.rb', line 25

def append_inclusions(*inclusions)
  extra_inclusions.concat(inclusions)
  descendants.each do |model|
    inclusions.each { |inclusion| model.send(:include, inclusion) }
  end
end

#descendantsObject



12
13
14
# File 'lib/mongo_mapper/support/descendant_appends.rb', line 12

def descendants
  @descendants ||= Set.new
end

#extra_extensionsObject

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.



33
34
35
# File 'lib/mongo_mapper/support/descendant_appends.rb', line 33

def extra_extensions
  @extra_extensions ||= []
end

#extra_inclusionsObject

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.



38
39
40
# File 'lib/mongo_mapper/support/descendant_appends.rb', line 38

def extra_inclusions
  @extra_inclusions ||= []
end

#included(model) ⇒ Object



5
6
7
8
9
# File 'lib/mongo_mapper/support/descendant_appends.rb', line 5

def included(model)
  extra_extensions.each { |extension| model.extend(extension) }
  extra_inclusions.each { |inclusion| model.send(:include, inclusion) }
  descendants << model
end