Class: Sunspot::Rails::Adapters::ActiveRecordDataAccessor
- Inherits:
-
Adapters::DataAccessor
- Object
- Adapters::DataAccessor
- Sunspot::Rails::Adapters::ActiveRecordDataAccessor
- Defined in:
- lib/sunspot/rails/adapters.rb
Instance Attribute Summary collapse
-
#include ⇒ Object
options for the find.
-
#select ⇒ Object
options for the find.
Instance Method Summary collapse
-
#load(id) ⇒ Object
Get one ActiveRecord instance out of the database by ID.
-
#load_all(ids) ⇒ Object
Get a collection of ActiveRecord instances out of the database by ID.
Instance Attribute Details
#include ⇒ Object
options for the find
36 37 38 |
# File 'lib/sunspot/rails/adapters.rb', line 36 def include @include end |
#select ⇒ Object
options for the find
36 37 38 |
# File 'lib/sunspot/rails/adapters.rb', line 36 def select @select end |
Instance Method Details
#load(id) ⇒ Object
Get one ActiveRecord instance out of the database by ID
Parameters
- id<String>
-
Database ID of model to retreive
Returns
- ActiveRecord::Base
-
ActiveRecord model
62 63 64 65 66 |
# File 'lib/sunspot/rails/adapters.rb', line 62 def load(id) @clazz.first(.merge( :conditions => { @clazz.primary_key => id.to_i} )) end |
#load_all(ids) ⇒ Object
Get a collection of ActiveRecord instances out of the database by ID
Parameters
- ids<Array>
-
Database IDs of models to retrieve
Returns
- Array
-
Collection of ActiveRecord models
79 80 81 82 83 |
# File 'lib/sunspot/rails/adapters.rb', line 79 def load_all(ids) @clazz.all(.merge( :conditions => { @clazz.primary_key => ids.map { |id| id.to_i }} )) end |