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
Calls superclass method
# 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
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
Private Instance Methods
relation()
click to toggle source
COMPATIBILITY: Rails
4 has deprecated the 'scoped' method in favour of 'all'
# File lib/sunspot/rails/adapters.rb, line 88 def relation ::Rails.version >= '4' ? @clazz.all : @clazz.scoped end
scope_for_load()
click to toggle source
# File lib/sunspot/rails/adapters.rb, line 77 def scope_for_load scope = relation scope = scope.includes(@include) if @include.present? scope = scope.select(@select) if @select.present? Array.wrap(@scopes).each do |s| scope = scope.send(s) end scope end