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
23
# File 'lib/mongo_mapper/support/descendant_appends.rb', line 17

def append_extensions(*extensions)
  warn "[DEPRECATED] append_extensions is deprecated. Use #plugin with a module that extends ActiveSupport::Concern."
  extra_extensions.concat(extensions)
  direct_descendants.each do |model|
    extensions.each { |extension| model.extend(extension) }
  end
end

#append_inclusions(*inclusions) ⇒ Object



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

def append_inclusions(*inclusions)
  warn "[DEPRECATED] append_inclusions is deprecated. Use #plugin with a module that extends ActiveSupport::Concern."
  extra_inclusions.concat(inclusions)
  direct_descendants.each do |model|
    inclusions.each { |inclusion| model.send(:include, inclusion) }
  end
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.



35
36
37
# File 'lib/mongo_mapper/support/descendant_appends.rb', line 35

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.



40
41
42
# File 'lib/mongo_mapper/support/descendant_appends.rb', line 40

def extra_inclusions
  @extra_inclusions ||= []
end

#included(model = nil, &block) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/mongo_mapper/support/descendant_appends.rb', line 7

def included(model = nil, &block)
  if model
    extra_extensions.each { |extension| model.extend(extension) }
    extra_inclusions.each { |inclusion| model.send(:include, inclusion) }
    direct_descendants << model
  end
  super
end