Sha256: d6d74af9b6ed3fed3fa521b37d947af32d07a487781af8b669beacef9502d070
Contents?: true
Size: 1.29 KB
Versions: 1
Compression:
Stored size: 1.29 KB
Contents
module DuckPuncher module Ducks module ActiveRecord def self.included(base) base.extend(ClassMethods) end def associations? associations.present? end def associations reflections.select { |key, reflection| begin if reflection.macro.to_s =~ /many/ send(key).exists? else send(key).present? end rescue nil end }.keys end module ClassMethods def except_for(*ids) scoped.where("#{quoted_table_name}.#{primary_key} NOT IN (?)", ids) end def since(time) scoped.where("#{quoted_table_name}.created_at > ?", time) end alias created_since since def before(time) scoped.where("#{quoted_table_name}.created_at < ?", time) end def updated_since(time) scoped.where("#{quoted_table_name}.updated_at > ?", time) end def between(start_at, end_at) scoped.where("#{quoted_table_name}.created_at BETWEEN ? AND ", start_at, end_at) end # shim for backwards compatibility with Rails 3 def scoped where(nil) end if ::Rails::VERSION::MAJOR > 3 end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
duck_puncher-4.5.0 | lib/duck_puncher/ducks/active_record.rb |