module Daterange
Public Instance Methods
active_now?()
click to toggle source
# File lib/acts_as_daterange/daterange.rb, line 55 def active_now? started? and not ended? end
expire()
click to toggle source
# File lib/acts_as_daterange/daterange.rb, line 45 def expire write_attribute(start_column, nil) write_attribute(expire_column, Time.now) end
expire!()
click to toggle source
# File lib/acts_as_daterange/daterange.rb, line 50 def expire! update_attribute(start_column, nil) update_attribute(expire_column, Time.now) end
expire_column()
click to toggle source
# File lib/acts_as_daterange/daterange.rb, line 37 def expire_column self.class.expire_column end
start_column()
click to toggle source
# File lib/acts_as_daterange/daterange.rb, line 41 def start_column self.class.start_column end
Private Instance Methods
daterange_period()
click to toggle source
# File lib/acts_as_daterange/daterange.rb, line 61 def daterange_period errors[start_column] << "must be present" if !self[start_column] errors[expire_column] << "be present" if !self[expire_column] if self[expire_column] < self[start_column] errors[expire_column] << "must be after #{start_column}" end end
ended?()
click to toggle source
# File lib/acts_as_daterange/daterange.rb, line 74 def ended? expire_col = read_attribute(expire_column) expire_col && expire_col < Time.now end
started?()
click to toggle source
# File lib/acts_as_daterange/daterange.rb, line 69 def started? start_col = read_attribute(start_column) start_col.nil? || start_col < Time.now end