Module: PeriodicRecords::Model::ClassMethods

Defined in:
lib/periodic_records/model.rb

Instance Method Summary collapse

Instance Method Details

#currentObject



27
28
29
30
# File 'lib/periodic_records/model.rb', line 27

def current
  date = Date.current
  within_date(date)
end

#from_date(date) ⇒ Object



32
33
34
35
# File 'lib/periodic_records/model.rb', line 32

def from_date(date)
  t = arel_table
  where(t[:end_at].gteq(date))
end

#within_date(date) ⇒ Object



23
24
25
# File 'lib/periodic_records/model.rb', line 23

def within_date(date)
  within_interval(date, date)
end

#within_interval(start_date, end_date) ⇒ Object



17
18
19
20
21
# File 'lib/periodic_records/model.rb', line 17

def within_interval(start_date, end_date)
  t = arel_table
  where(t[:start_at].lteq(end_date)).
  where(t[:end_at].gteq(start_date))
end