Module: Daterange::ClassMethods
- Defined in:
- lib/acts_as_daterange/daterange.rb
Instance Method Summary collapse
- #active_at(time) ⇒ Object
- #active_now ⇒ Object
- #expire_column ⇒ Object
- #inactive_at(time) ⇒ Object
- #inactive_now ⇒ Object
- #start_column ⇒ Object
Instance Method Details
#active_at(time) ⇒ Object
17 18 19 20 21 |
# File 'lib/acts_as_daterange/daterange.rb', line 17 def active_at(time) where("(#{start_column} IS NULL OR #{start_column} <= :time) AND (#{expire_column} IS NULL OR #{expire_column} > :time)", time: time) end |
#active_now ⇒ Object
28 29 30 |
# File 'lib/acts_as_daterange/daterange.rb', line 28 def active_now active_at(Time.now) end |
#expire_column ⇒ Object
9 10 11 |
# File 'lib/acts_as_daterange/daterange.rb', line 9 def expire_column daterange_config[:expire_column] end |
#inactive_at(time) ⇒ Object
23 24 25 26 |
# File 'lib/acts_as_daterange/daterange.rb', line 23 def inactive_at(time) where("#{start_column} > :time OR #{expire_column} < :time", time: time) end |
#inactive_now ⇒ Object
32 33 34 |
# File 'lib/acts_as_daterange/daterange.rb', line 32 def inactive_now inactive_at(Time.now) end |
#start_column ⇒ Object
13 14 15 |
# File 'lib/acts_as_daterange/daterange.rb', line 13 def start_column daterange_config[:start_column] end |