Module: Mongoid::Document::ClassMethods
- Defined in:
- lib/mongoid/document.rb
Overview
:nodoc:
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 ⇒ Object
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.
Instance Method Details
#===(other) ⇒ true, false
Performs class equality checking.
245 246 247 |
# File 'lib/mongoid/document.rb', line 245 def ===(other) self == (other.is_a?(Class) ? other : other.class) end |
#_types ⇒ Array<Class>
Returns all types to query for when using this class as the base.
274 275 276 |
# File 'lib/mongoid/document.rb', line 274 def _types @_type ||= [descendants + [self]].flatten.uniq.map(&:to_s) end |
#i18n_scope ⇒ Object
Set the i18n scope to overwrite ActiveModel.
279 280 281 |
# File 'lib/mongoid/document.rb', line 279 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.
258 259 260 261 262 263 264 265 266 |
# File 'lib/mongoid/document.rb', line 258 def instantiate(attrs = nil) attributes = attrs || {} allocate.tap do |doc| doc.instance_variable_set(:@attributes, attributes) doc.send(:apply_default_attributes) doc.setup_modifications doc.run_callbacks(:initialize) { doc } end end |