Module: Mongoid::Document::ClassMethods
- Defined in:
- lib/mongoid/document.rb
Instance Method Summary collapse
-
#===(other) ⇒ true, false
Performs class equality checking.
-
#_types ⇒ Array<Class>
Returns all types to query for when using this class as the base.
-
#i18n_scope ⇒ Symbol
Set the i18n scope to overwrite ActiveModel.
-
#instantiate(attrs = nil) ⇒ Document
Instantiate a new object, only when loaded from the database or when the attributes have already been typecast.
-
#logger ⇒ Logger
Returns the logger.
Instance Method Details
#===(other) ⇒ true, false
Performs class equality checking.
293 294 295 |
# File 'lib/mongoid/document.rb', line 293 def ===(other) other.class == Class ? self <= other : other.is_a?(self) end |
#_types ⇒ Array<Class>
Returns all types to query for when using this class as the base.
326 327 328 |
# File 'lib/mongoid/document.rb', line 326 def _types @_type ||= (descendants + [ self ]).uniq.map { |t| t.to_s } end |
#i18n_scope ⇒ Symbol
Set the i18n scope to overwrite ActiveModel.
335 336 337 |
# File 'lib/mongoid/document.rb', line 335 def i18n_scope :mongoid end |
#instantiate(attrs = nil) ⇒ Document
Instantiate a new object, only when loaded from the database or when the attributes have already been typecast.
308 309 310 311 312 313 314 315 316 |
# File 'lib/mongoid/document.rb', line 308 def instantiate(attrs = nil) attributes = attrs || {} doc = allocate doc.instance_variable_set(:@attributes, attributes) doc.apply_defaults IdentityMap.set(doc) unless _loading_revision? doc.run_callbacks(:initialize) unless doc._initialize_callbacks.empty? doc end |