summaryrefslogtreecommitdiff
path: root/app/models/concerns/closed_at_filterable.rb
blob: 239c2e476110d11779767bdddee788db33ee4f4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# frozen_string_literal: true

module ClosedAtFilterable
  extend ActiveSupport::Concern

  included do
    scope :closed_before, ->(date) { where(scoped_table[:closed_at].lteq(date)) }
    scope :closed_after, ->(date) { where(scoped_table[:closed_at].gteq(date)) }

    def self.scoped_table
      arel_table.alias(table_name)
    end
  end
end