Sha256: 8a401e45ec532ddeed1a77e90bb15d4143a178f37f3e2bf880eda9d19a1ad7d1

Contents?: true

Size: 1.25 KB

Versions: 12

Compression:

Stored size: 1.25 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)
        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(ids)
          @clazz.find(ids)
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
outoftime-sunspot_rails-0.10.0 lib/sunspot/rails/adapters.rb
outoftime-sunspot_rails-0.10.1 lib/sunspot/rails/adapters.rb
outoftime-sunspot_rails-0.9.10 lib/sunspot/rails/adapters.rb
outoftime-sunspot_rails-0.9.11 lib/sunspot/rails/adapters.rb
outoftime-sunspot_rails-0.9.12 lib/sunspot/rails/adapters.rb
outoftime-sunspot_rails-0.9.4 lib/sunspot/rails/adapters.rb
outoftime-sunspot_rails-0.9.6 lib/sunspot/rails/adapters.rb
outoftime-sunspot_rails-0.9.7 lib/sunspot/rails/adapters.rb
outoftime-sunspot_rails-0.9.8 lib/sunspot/rails/adapters.rb
outoftime-sunspot_rails-0.9.9 lib/sunspot/rails/adapters.rb
pallan-sunspot_rails-0.9.10 lib/sunspot/rails/adapters.rb
pallan-sunspot_rails-0.9.12 lib/sunspot/rails/adapters.rb