Module: Housekeeping::Timestamps::ClassMethods
- Defined in:
- lib/housekeeping/timestamps.rb
Instance Method Summary collapse
-
#created_in_last(time) ⇒ Scope
Otu.created_in_last(2.weeks).
- #created_last(number = 10) ⇒ Scope
- #created_this_week ⇒ Scope
- #created_today ⇒ Scope
- #first_created ⇒ Scope
- #first_updated ⇒ Scope
- #last_created ⇒ Scope
- #last_updated ⇒ Scope
-
#updated_in_last(time) ⇒ Scope
Otu.created_in_last(1.month).
- #updated_last(number = 10) ⇒ Scope
- #updated_this_week ⇒ Scope
- #updated_today ⇒ Scope
Instance Method Details
#created_in_last(time) ⇒ Scope
Otu.created_in_last(2.weeks)
69 70 71 |
# File 'lib/housekeeping/timestamps.rb', line 69 def created_in_last(time) where(created_at: time.ago..Time.now) end |
#created_last(number = 10) ⇒ Scope
80 81 82 |
# File 'lib/housekeeping/timestamps.rb', line 80 def created_last(number = 10) limit(number).order(created_at: :DESC) end |
#created_this_week ⇒ Scope
48 49 50 |
# File 'lib/housekeeping/timestamps.rb', line 48 def created_this_week where(created_at: 1.week.ago..Time.now) end |
#created_today ⇒ Scope
58 59 60 |
# File 'lib/housekeeping/timestamps.rb', line 58 def created_today where(created_at: 1.day.ago..Time.now) end |
#first_created ⇒ Scope
28 29 30 |
# File 'lib/housekeeping/timestamps.rb', line 28 def first_created all.order(created_at: :asc).first end |
#first_updated ⇒ Scope
38 39 40 |
# File 'lib/housekeeping/timestamps.rb', line 38 def first_updated all.order(updated_at: :asc).first end |
#last_created ⇒ Scope
33 34 35 |
# File 'lib/housekeeping/timestamps.rb', line 33 def last_created all.order(created_at: :desc).first end |
#last_updated ⇒ Scope
43 44 45 |
# File 'lib/housekeeping/timestamps.rb', line 43 def last_updated all.order(updated_at: :desc).first end |
#updated_in_last(time) ⇒ Scope
Otu.created_in_last(1.month)
75 76 77 |
# File 'lib/housekeeping/timestamps.rb', line 75 def updated_in_last(time) where(updated_at: time.ago..Time.now) end |
#updated_last(number = 10) ⇒ Scope
85 86 87 |
# File 'lib/housekeeping/timestamps.rb', line 85 def updated_last(number = 10) limit(number).order(updated_at: :DESC) end |
#updated_this_week ⇒ Scope
53 54 55 |
# File 'lib/housekeeping/timestamps.rb', line 53 def updated_this_week where(updated_at: 1.week.ago..Time.now) end |
#updated_today ⇒ Scope
63 64 65 |
# File 'lib/housekeeping/timestamps.rb', line 63 def updated_today where(updated_at: 1.day.ago..Time.now) end |