Class: Sunspot::Mongo::DataAccessor
- Inherits:
-
Adapters::DataAccessor
- Object
- Adapters::DataAccessor
- Sunspot::Mongo::DataAccessor
- Defined in:
- lib/sunspot/mongo.rb
Instance Attribute Summary collapse
-
#include ⇒ Object
Returns the value of attribute include.
Instance Method Summary collapse
-
#initialize(clazz) ⇒ DataAccessor
constructor
A new instance of DataAccessor.
- #load(id) ⇒ Object
- #load_all(ids) ⇒ Object
Constructor Details
#initialize(clazz) ⇒ DataAccessor
Returns a new instance of DataAccessor.
23 24 25 26 |
# File 'lib/sunspot/mongo.rb', line 23 def initialize(clazz) super(clazz) @inherited_attributes = [:include] end |
Instance Attribute Details
#include ⇒ Object
Returns the value of attribute include.
21 22 23 |
# File 'lib/sunspot/mongo.rb', line 21 def include @include end |
Instance Method Details
#load(id) ⇒ Object
28 29 30 |
# File 'lib/sunspot/mongo.rb', line 28 def load(id) @clazz.find(id) end |
#load_all(ids) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/sunspot/mongo.rb', line 32 def load_all(ids) if @include.present? @clazz.includes(@include).find(ids) else @clazz.find(ids) end end |