Module: ChronoModel::TimeMachine::ClassMethods

Defined in:
lib/chrono_model/time_machine.rb

Instance Method Summary collapse

Instance Method Details

#as_of(time) ⇒ Object

Returns an ActiveRecord::Relation on the history of this model as it was time ago.



101
102
103
# File 'lib/chrono_model/time_machine.rb', line 101

def as_of(time)
  history.as_of(time)
end

#attribute_names_for_history_changesObject



105
106
107
108
# File 'lib/chrono_model/time_machine.rb', line 105

def attribute_names_for_history_changes
  @attribute_names_for_history_changes ||= attribute_names -
    %w( id hid validity recorded_at )
end

#has_timeline(options) ⇒ Object



110
111
112
113
114
115
116
117
118
# File 'lib/chrono_model/time_machine.rb', line 110

def has_timeline(options)
  changes = options.delete(:changes)
  assocs  = history.has_timeline(options)

  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.

Returns:

  • (Boolean)


95
96
97
# File 'lib/chrono_model/time_machine.rb', line 95

def history?
  false
end