Class: PaperTrail::RecordHistory Private

Inherits:
Object
  • Object
show all
Defined in:
lib/paper_trail/record_history.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Represents the history of a single record.

Instance Method Summary collapse

Constructor Details

#initialize(versions, version_class) ⇒ RecordHistory

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of RecordHistory.

Parameters:

  • versions
    • ActiveRecord::Relation - All versions of the record.

  • version_class
    • Class - Usually PaperTrail::Version,

    but it could also be a custom version class.



11
12
13
14
# File 'lib/paper_trail/record_history.rb', line 11

def initialize(versions, version_class)
  @versions = versions
  @version_class = version_class
end

Instance Method Details

#index(version) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns ordinal position of ‘version` in `sequence`.



18
19
20
# File 'lib/paper_trail/record_history.rb', line 18

def index(version)
  sequence.to_a.index(version)
end