Sha256: 435734291783f4bff115984b0d3d5f72e1eff50c319ee9e84e0de4abf3409158
Contents?: true
Size: 1.27 KB
Versions: 23
Compression:
Stored size: 1.27 KB
Contents
module Sunspot #:nodoc: module Rails #:nodoc: # # This module provides Sunspot Adapter implementations for ActiveRecord # models. # module Adapters class ActiveRecordInstanceAdapter < Sunspot::Adapters::InstanceAdapter # # Return the primary key for the adapted instance # # ==== Returns # # Integer:: Database ID of model # def id @instance.id end end class ActiveRecordDataAccessor < Sunspot::Adapters::DataAccessor # # Get one ActiveRecord instance out of the database by ID # # ==== Parameters # # id<String>:: Database ID of model to retreive # # ==== Returns # # ActiveRecord::Base:: ActiveRecord model # def load(id) @clazz.find(id.to_i) end # # 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 # def load_all(ids) @clazz.find(ids.map { |id| id.to_i }) end end end end end
Version data entries
23 entries across 23 versions & 10 rubygems