Module: Pageflow::RevisionComponent

Extended by:
ActiveSupport::Concern
Defined in:
lib/pageflow/revision_component.rb

Overview

RevisionComponent represents a model that is attached to the revision mechanism of Pageflow.

In order to be used as a ComponentModel a model is required to have an integer field `perma_id` and a belongs_to field `revision`.

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#copy_to(revision) ⇒ Object


15
16
17
18
19
# File 'lib/pageflow/revision_component.rb', line 15

def copy_to(revision)
  record = dup
  record.revision = revision
  record.save!
end

#ensure_perma_idObject


21
22
23
# File 'lib/pageflow/revision_component.rb', line 21

def ensure_perma_id
  self.perma_id ||= (self.class.maximum(:perma_id) || 0) + 1
end