Module: ChronoModel::TimeMachine::ClassMethods
- Defined in:
- lib/chrono_model/time_machine.rb
Instance Method Summary collapse
-
#as_of(time) ⇒ Object
Returns an ActiveRecord::Relation on the history of this model as it was
timeago. - #attribute_names_for_history_changes ⇒ Object
- #has_timeline(options) ⇒ Object
-
#history? ⇒ Boolean
Identify this class as the parent, non-history, class.
Instance Method Details
#as_of(time) ⇒ Object
Returns an ActiveRecord::Relation on the history of this model as it was time ago.
349 350 351 |
# File 'lib/chrono_model/time_machine.rb', line 349 def as_of(time) history.as_of(time) end |
#attribute_names_for_history_changes ⇒ Object
353 354 355 356 |
# File 'lib/chrono_model/time_machine.rb', line 353 def attribute_names_for_history_changes @attribute_names_for_history_changes ||= attribute_names - %w( id hid validity recorded_at ) end |
#has_timeline(options) ⇒ Object
358 359 360 361 362 363 364 365 366 |
# File 'lib/chrono_model/time_machine.rb', line 358 def has_timeline() changes = .delete(:changes) assocs = history.has_timeline() attributes = changes.present? ? Array.wrap(changes) : assocs.map(&:name) attribute_names_for_history_changes.concat(attributes.map(&:to_s)) end |
#history? ⇒ Boolean
Identify this class as the parent, non-history, class.
343 344 345 |
# File 'lib/chrono_model/time_machine.rb', line 343 def history? false end |