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.



322
323
324
# File 'lib/chrono_model/time_machine.rb', line 322

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

#attribute_names_for_history_changesObject



326
327
328
329
# File 'lib/chrono_model/time_machine.rb', line 326

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

#has_timeline(options) ⇒ Object



331
332
333
334
335
336
337
338
339
# File 'lib/chrono_model/time_machine.rb', line 331

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