Module: DateScope::Extension

Defined in:
lib/datescope/base.rb

Instance Method Summary collapse

Instance Method Details

#last_monthObject



16
17
18
# File 'lib/datescope/base.rb', line 16

def last_month
  where("created_at >= ? and created_at <= ?", 1.month.ago.beginning_of_month, 1.month.ago.end_of_month)
end

#month_before_last_monthObject



20
21
22
# File 'lib/datescope/base.rb', line 20

def month_before_last_month
  where("created_at >= ? and created_at <= ?", 2.month.ago.beginning_of_month, 2.month.ago.end_of_month)
end

#this_monthObject



12
13
14
# File 'lib/datescope/base.rb', line 12

def this_month
  where("created_at >= ?", 0.month.ago.beginning_of_month)
end

#this_weekObject



8
9
10
# File 'lib/datescope/base.rb', line 8

def this_week
  where("created_at >= ?", 0.week.ago.beginning_of_week)
end

#this_yearObject



24
25
26
# File 'lib/datescope/base.rb', line 24

def this_year
  where("created_at >= ?", 0.year.ago.beginning_of_year)
end

#todayObject



4
5
6
# File 'lib/datescope/base.rb', line 4

def today
  where("created_at >= ?", 0.day.ago.beginning_of_day)
end