Module: ActsAsHistorical::InstanceMethods
- Defined in:
- lib/acts_as_historical.rb
Instance Method Summary collapse
- #next ⇒ Object
- #previous ⇒ Object
-
#to_date ⇒ Object
override with your date implementation.
- #valid_date? ⇒ Boolean
Instance Method Details
#next ⇒ Object
154 |
# File 'lib/acts_as_historical.rb', line 154 def next; find_record_at(snapshot_date + 1); end |
#previous ⇒ Object
153 |
# File 'lib/acts_as_historical.rb', line 153 def previous; find_record_at(snapshot_date - 1); end |
#to_date ⇒ Object
override with your date implementation. eg. Weekday
def snapshot_date
self[self.class.historical_date_col]
end
162 163 164 |
# File 'lib/acts_as_historical.rb', line 162 def to_date snapshot_date and snapshot_date.to_date end |
#valid_date? ⇒ Boolean
141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/acts_as_historical.rb', line 141 def valid_date? if self.to_date.nil? errors.add_to_base('date missing') return false end if self.to_date >= Date.tomorrow errors.add_to_base('date is in future') return false end true end |