Module: Mongoid::Extras::ClassMethods
- Defined in:
- lib/mongoid/extras.rb
Overview
:nodoc
Instance Method Summary collapse
-
#cache ⇒ Object
Sets caching on for this class.
-
#cached? ⇒ Boolean
Determines if the class is cached or not.
-
#enslave ⇒ Object
Set whether or not this documents read operations should delegate to the slave database by default.
-
#enslaved? ⇒ Boolean
Determines if the class is enslaved or not.
Instance Method Details
#cache ⇒ Object
Sets caching on for this class. This class level configuration will default all queries to cache the results of the first iteration over the cursor into an internal array. This should only be used for queries that return a small number of results or have small documents, as after the first iteration the entire results will be stored in memory.
Example:
class Person
include Mongoid::Document
cache
end
28 29 30 |
# File 'lib/mongoid/extras.rb', line 28 def cache self.cached = true end |
#cached? ⇒ Boolean
Determines if the class is cached or not.
Returns:
True if cached, false if not.
37 38 39 |
# File 'lib/mongoid/extras.rb', line 37 def cached? !!self.cached end |
#enslave ⇒ Object
50 51 52 |
# File 'lib/mongoid/extras.rb', line 50 def enslave self.enslaved = true end |
#enslaved? ⇒ Boolean
Determines if the class is enslaved or not.
Returns:
True if enslaved, false if not.
59 60 61 |
# File 'lib/mongoid/extras.rb', line 59 def enslaved? !!self.enslaved end |