lib/arid_cache/cache_proxy/result_processor.rb
def fetch_activerecords(records)
        @options[:result_klass] = result_klass

        if records.empty?
          if @options.paginate?
            return records.paginate(@options.opts_for_paginate(records))
          else
            return records
          end
        end

        ids = AridCache.framework.active_record? && records.first.is_a?(ActiveRecord) ? records.collect { |record| record[:id] } : records
        find_opts = @options.opts_for_find(ids)
        if order_in_database?
          if @options.paginate?
            if AridCache.framework.active_record?(:>=, 3)
              page_opts = @options.opts_for_paginate(ids)
              WillPaginate::Collection.create(page_opts[:page], page_opts[:per_page], page_opts[:total_entries]) do |pager|
                result = AridCache.find_all_by_id(result_klass, ids, find_opts.merge(:limit => pager.per_page, :offset => pager.offset))
                pager.replace(result)
              end
            else
              find_opts.merge!(@options.opts_for_paginate(ids))
              result_klass.paginate(ids, find_opts)
            end
          else
            AridCache.find_all_by_id(result_klass, ids, find_opts)
          end
        else
          # Limits will have already been applied, remove them from the options for find.
          [:offset, :limit].each { |key| find_opts.delete(key) }
          result = AridCache.find_all_by_id(result_klass, ids, find_opts)

          # Order in memory
          if @options.order_by_proc?
            result.sort!(&@options[:order])
          elsif AridCache.order_in_memory?
            object_map =
              result.inject({}) do |hash, record|
                hash[record.id] = record unless record.nil?
                hash
              end
            result = 
              ids.inject([]) do |array, id|
                if value = object_map[id]
                  array << value
                end
                array
              end
          end
          records.is_a?(::WillPaginate::Collection) ? records.replace(result) : result
        end
      end
# Return a list of records from the database.  +records+ is a list of
# ActiveRecords or a list of ActiveRecord ids.
#
# If no :order is specified, the current order is preserved with some fancy SQL.
# If an arder is specified then
# order, limit and paginate in the database.
Return a list of records from the database.  +records+ is a list of
ActiveRecords or a list of ActiveRecord ids.

If no :order is specified, the current order is preserved with some fancy SQL.
If an arder is specified then
order, limit and paginate in the database.
Return a list of records from the database . + records + is a list of ActiveRecords or a list of ActiveRecord ids . If no : order is specified the current order is preserved with some fancy SQL . If an arder is specified then order limit and paginate in the database .
def fetch_activerecords(records)
        @options[:result_klass] = result_klass
        if records.empty?
          if @options.paginate?
            return records.paginate(@options.opts_for_paginate(records))
          else
            return records
          end
        end
        ids = AridCache.framework.active_record? && records.first.is_a?(ActiveRecord) ? records.collect { |record| record[:id] } : records
        find_opts = @options.opts_for_find(ids)
        if order_in_database?
          if @options.paginate?
            if AridCache.framework.active_record?(:>=, 3)
              page_opts = @options.opts_for_paginate(ids)
              WillPaginate::Collection.create(page_opts[:page], page_opts[:per_page], page_opts[:total_entries]) do |pager|
                result = AridCache.find_all_by_id(result_klass, ids, find_opts.merge(:limit => pager.per_page, :offset => pager.offset))
                pager.replace(result)
              end
            else
              find_opts.merge!(@options.opts_for_paginate(ids))
              result_klass.paginate(ids, find_opts)
            end
          else
            AridCache.find_all_by_id(result_klass, ids, find_opts)
          end
        else
          [:offset, :limit].each { |key| find_opts.delete(key) }
          result = AridCache.find_all_by_id(result_klass, ids, find_opts)
          if @options.order_by_proc?
            result.sort!(&@options[:order])
          elsif AridCache.order_in_memory?
            object_map =
              result.inject({}) do |hash, record|
                hash[record.id] = record unless record.nil?
                hash
              end
            result = 
              ids.inject([]) do |array, id|
                if value = object_map[id]
                  array << value
                end
                array
              end
          end
          records.is_a?(::WillPaginate::Collection) ? records.replace(result) : result
        end
      end
def fetch_activerecords ( records ) @options [ :result_klass ] = result_klass if records . empty? if @options . paginate? return records . paginate ( @options . opts_for_paginate ( records ) ) else return records end end ids = AridCache . framework . active_record? && records . first . is_a? ( ActiveRecord ) ? records . collect { | record | record [ :id ] } : records find_opts = @options . opts_for_find ( ids ) if order_in_database? if @options . paginate? if AridCache . framework . active_record? ( :>= , 3 ) page_opts = @options . opts_for_paginate ( ids ) WillPaginate :: Collection . create ( page_opts [ :page ] , page_opts [ :per_page ] , page_opts [ :total_entries ] ) do | pager | result = AridCache . find_all_by_id ( result_klass , ids , find_opts . merge ( :limit => pager . per_page , :offset => pager . offset ) ) pager . replace ( result ) end else find_opts . merge! ( @options . opts_for_paginate ( ids ) ) result_klass . paginate ( ids , find_opts ) end else AridCache . find_all_by_id ( result_klass , ids , find_opts ) end else [ :offset , :limit ] . each { | key | find_opts . delete ( key ) } result = AridCache . find_all_by_id ( result_klass , ids , find_opts ) if @options . order_by_proc? result . sort! ( & @options [ :order ] ) elsif AridCache . order_in_memory? object_map = result . inject ( { } ) do | hash , record | hash [ record . id ] = record unless record . nil? hash end result = ids . inject ( [ ] ) do | array , id | if value = object_map [ id ] array << value end array end end records . is_a? ( :: WillPaginate :: Collection ) ? records . replace ( result ) : result end end
Return a list of records from the database.
Return a list of records from the database .
# Limits will have already been applied, remove them from the options for find. # Order in memory
records