# File lib/paper_trail/record_history.rb, line 40 def primary_key table[@version_class.primary_key] end
class PaperTrail::RecordHistory
Represents the history of a single record. @api private
Public Class Methods
new(versions, version_class)
click to toggle source
@param versions - ActiveRecord::Relation - All versions of the record. @param version_class - Class - Usually PaperTrail::Version
,
but it could also be a custom version class.
@api private
# File lib/paper_trail/record_history.rb, line 11 def initialize(versions, version_class) @versions = versions @version_class = version_class end
Public Instance Methods
index(version)
click to toggle source
Returns ordinal position of ‘version` in `sequence`. @api private
# File lib/paper_trail/record_history.rb, line 18 def index(version) sequence.to_a.index(version) end
Private Instance Methods
primary_key()
click to toggle source
@return - Arel::Attribute - Attribute representing the primary key
of the version table. The column's data type is usually a serial integer (the rails convention) but not always.
@api private
sequence()
click to toggle source
Returns ‘@versions` in chronological order. @api private
# File lib/paper_trail/record_history.rb, line 26 def sequence if @version_class.primary_key_is_int? @versions.select(primary_key).order(primary_key.asc) else @versions. select([table[:created_at], primary_key]). order(@version_class.timestamp_sort_order) end end
table()
click to toggle source
@return - Arel::Table - The version table, usually named ‘versions`, but
not always.
@api private
# File lib/paper_trail/record_history.rb, line 47 def table @version_class.arel_table end