Class: Sunspot::Rails::Adapters::ActiveRecordDataAccessor
- Inherits:
-
Adapters::DataAccessor
- Object
- Adapters::DataAccessor
- Sunspot::Rails::Adapters::ActiveRecordDataAccessor
- Defined in:
- sunspot_rails/lib/sunspot/rails/adapters.rb
Instance Attribute Summary (collapse)
-
- (Object) include
options for the find.
-
- (Object) select
options for the find.
Instance Method Summary (collapse)
-
- (Object) load(id)
Get one ActiveRecord instance out of the database by ID.
-
- (Object) load_all(ids)
Get a collection of ActiveRecord instances out of the database by ID.
Methods inherited from Adapters::DataAccessor
create, for, #initialize, register
Constructor Details
This class inherits a constructor from Sunspot::Adapters::DataAccessor
Instance Attribute Details
- (Object) include
options for the find
23 24 25 |
# File 'sunspot_rails/lib/sunspot/rails/adapters.rb', line 23 def include @include end |
- (Object) select
options for the find
23 24 25 |
# File 'sunspot_rails/lib/sunspot/rails/adapters.rb', line 23 def select @select end |
Instance Method Details
- (Object) load(id)
Get one ActiveRecord instance out of the database by ID
Parameters
id | Database ID of model to retreive |
Returns
ActiveRecord::Base | ActiveRecord model |
49 50 51 52 53 |
# File 'sunspot_rails/lib/sunspot/rails/adapters.rb', line 49 def load(id) @clazz.first(.merge( :conditions => { @clazz.primary_key => id} )) end |
- (Object) load_all(ids)
Get a collection of ActiveRecord instances out of the database by ID
Parameters
ids | Database IDs of models to retrieve |
Returns
Array | Collection of ActiveRecord models |
66 67 68 69 70 |
# File 'sunspot_rails/lib/sunspot/rails/adapters.rb', line 66 def load_all(ids) @clazz.all(.merge( :conditions => { @clazz.primary_key => ids.map { |id| id }} )) end |