class Sunspot::Rails::Adapters::ActiveRecordDataAccessor

Attributes

include[RW]

options for the find

scopes[RW]
select[R]

Public Class Methods

new(clazz) click to toggle source
# File lib/sunspot/rails/adapters.rb, line 27
def initialize(clazz)
  super(clazz)
  @inherited_attributes = [:include, :select, :scopes]
end

Public Instance Methods

load(id) click to toggle source

Get one ActiveRecord instance out of the database by ID

Parameters

id<String>

Database ID of model to retreive

Returns

ActiveRecord::Base

ActiveRecord model

# File lib/sunspot/rails/adapters.rb, line 56
def load(id)
  @clazz.where(@clazz.primary_key => id).merge(scope_for_load).first
end
load_all(ids) click to toggle source

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

# File lib/sunspot/rails/adapters.rb, line 71
def load_all(ids)
  @clazz.where(@clazz.primary_key => ids).merge(scope_for_load)
end
select=(value) click to toggle source

Set the fields to select from the database. This will be passed to ActiveRecord.

Parameters

value<Mixed>

String of comma-separated columns or array of columns

# File lib/sunspot/rails/adapters.rb, line 40
def select=(value)
  value = value.join(', ') if value.respond_to?(:join)
  @select = value
end