Sha256: 6f92d438f94f127fab399305386b0565a68ef651cb1d7ca5cd809d607ffb9017

Contents?: true

Size: 824 Bytes

Versions: 2

Compression:

Stored size: 824 Bytes

Contents

require "find_with_order/version"
require "find_with_order/mysql_support"
require "find_with_order/pg_support"
require 'active_record'

class << ActiveRecord::Base
  def find_with_order(ids)
    return none if ids.blank?
    ids = ids.uniq
    return FindWithOrder::PGSupport.find_with_order(self, ids) if defined?(PG)
    return FindWithOrder::MysqlSupport.find_with_order(self, ids)
  end
  def where_with_order(column, ids)
    return none if ids.blank?
    ids = ids.uniq
    return FindWithOrder::PGSupport.where_with_order(self, column, ids) if defined?(PG)
    return FindWithOrder::MysqlSupport.where_with_order(self, column, ids)
  end
end
unless ActiveRecord::Base.respond_to?(:none) # extend only if not implement yet
  class ActiveRecord::Base
    def self.none #For Rails 3
      where('1=0')
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
find_with_order-1.1.1 lib/find_with_order.rb
find_with_order-1.1.0 lib/find_with_order.rb