Sha256: 94a99f8e4a8c0b2a3c6c3b459316b3d71cbc953d58410ffc73a21b54783aeff6

Contents?: true

Size: 871 Bytes

Versions: 1

Compression:

Stored size: 871 Bytes

Contents

module Season
  module Scopes

    def self.included(base)
      base.class_eval do
        def self.created_before(date)
          where("#{table_name}.created_at < ?", date)
        end

        def self.created_between(start_date, end_date)
          where("#{table_name}.created_at > ? AND #{table_name}.created_at < ?", start_date, end_date)
        end

        def self.created_after(date)
          where("#{table_name}.created_at > ?", date)
        end

        def self.updated_before(date)
          where("#{table_name}.updated_at < ?", date)
        end

        def self.updated_between(start_date, end_date)
          where("#{table_name}.updated_at > ? AND #{table_name}.updated_at < ?", start_date, end_date)
        end

        def self.updated_after(date)
          where("#{table_name}.updated_at > ?", date)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
season-0.1 lib/season/active_record/scopes.rb