lib/arid_cache/cache_proxy/utilities.rb
def find_all_by_id(klass, ids, find_opts={})
        return ids if ids.empty?
        find_opts = Options.new(find_opts.merge(:result_klass => klass)).opts_for_find(ids)
        if AridCache.framework.active_record?(:>=, 3) # use Arel
          option_map = {
            :conditions => :where,
            :include => :includes
          }
          query = find_opts.inject(klass.scoped) do |scope, pair|
            key, value = pair
            key = option_map[key] || key
            scope.send(key, pair[1])
          end
          query = query.scoped.where(Utilities.namespaced_column(:id, klass) + ' in (?)', ids)
          # Fix http://breakthebit.org/post/3487560245/rails-3-arel-count-size-length-weirdness
          query.class_eval do
            alias_method :size, :length
            alias_method :count, :length
          end
          query
        else
          klass.find_all_by_id(ids, find_opts)
        end
      end
# Find and return records of the given +klass+ which have id in +ids+.
# +find_opts+ is a hash of options which are passed to find.
# If no order option is given, the ordering of the ids is preserved.
# No query is performed if +ids+ is empty.
Find and return records of the given +klass+ which have id in +ids+.
+find_opts+ is a hash of options which are passed to find.
If no order option is given, the ordering of the ids is preserved.
No query is performed if +ids+ is empty.
Find and return records of the given + klass + which have id in + ids + . + find_opts + is a hash of options which are passed to find . If no order option is given the ordering of the ids is preserved . No query is performed if + ids + is empty .
def find_all_by_id(klass, ids, find_opts={})
        return ids if ids.empty?
        find_opts = Options.new(find_opts.merge(:result_klass => klass)).opts_for_find(ids)
        if AridCache.framework.active_record?(:>=, 3) 
          option_map = {
            :conditions => :where,
            :include => :includes
          }
          query = find_opts.inject(klass.scoped) do |scope, pair|
            key, value = pair
            key = option_map[key] || key
            scope.send(key, pair[1])
          end
          query = query.scoped.where(Utilities.namespaced_column(:id, klass) + ' in (?)', ids)
          query.class_eval do
            alias_method :size, :length
            alias_method :count, :length
          end
          query
        else
          klass.find_all_by_id(ids, find_opts)
        end
      end
def find_all_by_id ( klass , ids , find_opts = { } ) return ids if ids . empty? find_opts = Options . new ( find_opts . merge ( :result_klass => klass ) ) . opts_for_find ( ids ) if AridCache . framework . active_record? ( :>= , 3 ) option_map = { :conditions => :where , :include => :includes } query = find_opts . inject ( klass . scoped ) do | scope , pair | key , value = pair key = option_map [ key ] || key scope . send ( key , pair [ 1 ] ) end query = query . scoped . where ( Utilities . namespaced_column ( :id , klass ) + ' in (?)' , ids ) query . class_eval do alias_method :size , :length alias_method :count , :length end query else klass . find_all_by_id ( ids , find_opts ) end end
Find and return records of the given +klass+ which have id in +ids+.
Find and return records of the given + klass + which have id in + ids + .
# use Arel # Fix http://breakthebit.org/post/3487560245/rails-3-arel-count-size-length-weirdness
klass
ids
find_opts