Class: Sunspot::Rails::Adapters::ActiveRecordDataAccessor
- Inherits:
-
Adapters::DataAccessor
- Object
- Adapters::DataAccessor
- Sunspot::Rails::Adapters::ActiveRecordDataAccessor
- Defined in:
- lib/sunspot/rails/adapters.rb
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 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
33 34 35 |
# File 'lib/sunspot/rails/adapters.rb', line 33 def load(id) @clazz.find(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
48 49 50 |
# File 'lib/sunspot/rails/adapters.rb', line 48 def load_all(ids) @clazz.find(ids.map { |id| id.to_i }) end |