Class: Sunspot::Rails::Adapters::ActiveRecordDataAccessor

Inherits:
Adapters::DataAccessor show all
Defined in:
sunspot_rails/lib/sunspot/rails/adapters.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

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(options_for_find.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(options_for_find.merge(
    :conditions => { @clazz.primary_key => ids.map { |id| id }}
  ))
end