Sha256: 7e2fd026fe83233416d9322443c309f532e481b4b4dd9fe3937e9f91f390fb3e

Contents?: true

Size: 872 Bytes

Versions: 5

Compression:

Stored size: 872 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

5 entries across 5 versions & 1 rubygems

Version Path
season-0.0.6 lib/season/active_record/scopes.rb
season-0.0.5 lib/season/active_record/scopes.rb
season-0.0.4 lib/season/active_record/scopes.rb
season-0.0.3 lib/season/active_record/scopes.rb
season-0.0.2 lib/season/active_record/scopes.rb