Module: MongoMapper::Document

Defined in:
lib/mongo_mapper/document.rb

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Class Method Summary collapse

Class Method Details

.append_extensions(*extensions) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/mongo_mapper/document.rb', line 31

def self.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



45
46
47
48
49
50
51
52
# File 'lib/mongo_mapper/document.rb', line 45

def self.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

.descendantsObject



27
28
29
# File 'lib/mongo_mapper/document.rb', line 27

def self.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.



41
42
43
# File 'lib/mongo_mapper/document.rb', line 41

def self.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.



55
56
57
# File 'lib/mongo_mapper/document.rb', line 55

def self.extra_inclusions
  @extra_inclusions ||= []
end

.included(model) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/mongo_mapper/document.rb', line 5

def self.included(model)
  model.class_eval do
    include EmbeddedDocument
    include InstanceMethods
    include Callbacks
    include Dirty
    include RailsCompatibility::Document
    extend Validations::Macros
    extend ClassMethods
    extend Finders

    def self.per_page
      25
    end unless respond_to?(:per_page)
  end

  extra_extensions.each { |extension| model.extend(extension) }
  extra_inclusions.each { |inclusion| model.send(:include, inclusion) }

  descendants << model
end