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
inspired by how Sunspot does this for ActiveRecord.
- #load(id) ⇒ Object
- #load_all(ids) ⇒ Object
- #scope ⇒ Object
Constructor Details
#initialize(clazz) ⇒ DataAccessor
inspired by how Sunspot does this for ActiveRecord
24 25 26 27 |
# File 'lib/sunspot/mongo.rb', line 24 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
29 30 31 |
# File 'lib/sunspot/mongo.rb', line 29 def load(id) scope.find(id) end |
#load_all(ids) ⇒ Object
33 34 35 |
# File 'lib/sunspot/mongo.rb', line 33 def load_all(ids) scope.find(ids) end |
#scope ⇒ Object
37 38 39 40 |
# File 'lib/sunspot/mongo.rb', line 37 def scope sc = @clazz.respond_to?(:criteria) ? @clazz.criteria : @clazz @include ? sc.includes(@include) : sc end |