1class Location < ActiveRecord::Base
 
2  validates :code, presence: true, length: { maximum: 30 }
 
3  validates :name, presence: true, length: { maximum: 100 }
 
4
 
5  class << self
 
6    def by_name
 
7      order(name: :asc)
 
8    end
 
 9
  • UnusedParameters - has unused parameter 'today' » reek
10    def current(today = Date.current)
 
11      not_pending.not_expired.by_name
 
12    end
 
 
14    def not_pending(today = Date.current)
 
15      where(start_date.eq(nil).or(start_date.lteq(today)))
 
16    end
 
 
18    def not_expired(today = Date.current)
 
19      where(end_date.eq(nil).or(end_date.gt(today)))
 
20    end
 
 
22    def menu
 
23      current.pluck(:name, :code)
 
24    end
 
 
26    private
 
 
28    def start_date
 
29      arel_table[:start_date]
 
30    end
 
 
32    def end_date
 
33      arel_table[:end_date]
 
34    end
 
35  end
 
36end