Module: MongoMapper::Support::DescendantAppends
- Included in:
- Document, EmbeddedDocument
- Defined in:
- lib/mongo_mapper/support/descendant_appends.rb
Instance Method Summary collapse
- #append_extensions(*extensions) ⇒ Object
- #append_inclusions(*inclusions) ⇒ Object
- #descendants ⇒ Object
- #extra_extensions ⇒ Object private
- #extra_inclusions ⇒ Object private
- #included(model) ⇒ Object
Instance Method Details
#append_extensions(*extensions) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/mongo_mapper/support/descendant_appends.rb', line 16 def append_extensions(*extensions) extra_extensions.concat extensions # Add the extension to existing descendants descendants.each do |model| extensions.each { |extension| model.extend(extension) } end end |
#append_inclusions(*inclusions) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/mongo_mapper/support/descendant_appends.rb', line 26 def append_inclusions(*inclusions) extra_inclusions.concat inclusions # Add the inclusion to existing descendants descendants.each do |model| inclusions.each { |inclusion| model.send(:include, inclusion) } end end |
#descendants ⇒ Object
11 12 13 |
# File 'lib/mongo_mapper/support/descendant_appends.rb', line 11 def descendants @descendants ||= Set.new end |
#extra_extensions ⇒ Object
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.
36 37 38 |
# File 'lib/mongo_mapper/support/descendant_appends.rb', line 36 def extra_extensions @extra_extensions ||= [] end |
#extra_inclusions ⇒ Object
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.
41 42 43 |
# File 'lib/mongo_mapper/support/descendant_appends.rb', line 41 def extra_inclusions @extra_inclusions ||= [] end |
#included(model) ⇒ Object
4 5 6 7 8 |
# File 'lib/mongo_mapper/support/descendant_appends.rb', line 4 def included(model) extra_extensions.each { |extension| model.extend(extension) } extra_inclusions.each { |inclusion| model.send(:include, inclusion) } descendants << model end |