Sha256: 8a42fec8f36f6d7b7437ee1b34c44432062ccfc57172d64b55166ec1b62fedb8

Contents?: true

Size: 1015 Bytes

Versions: 9

Compression:

Stored size: 1015 Bytes

Contents

require 'active_support/concern'

module Georgia
  module Concerns
    module Revisionable
      extend ActiveSupport::Concern

      included do

        has_many :revisions, as: :revisionable, dependent: :destroy
        belongs_to :current_revision, class_name: Georgia::Revision, foreign_key: :revision_id

        delegate :title, :text, :excerpt, :keywords, :keyword_list, :image, to: :current_revision, allow_nil: true
        delegate :template, :content, :slides, :widgets, to: :current_revision, allow_nil: true
        delegate :draft?, :review?, :revision?, to: :current_revision, allow_nil: true

        def draft
          Georgia::Clone.new(self).draft
        end

        def store
          Georgia::Clone.new(self).store
        end

        def copy
          Georgia::Clone.new(self).copy
        end

        def approve_revision revision
          current_revision.store if current_revision
          self.update_attribute(:revision_id, revision.id)
        end

      end

    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
georgia-0.7.8 app/models/georgia/concerns/revisionable.rb
georgia-0.7.7 app/models/georgia/concerns/revisionable.rb
georgia-0.7.6 app/models/georgia/concerns/revisionable.rb
georgia-0.7.5 app/models/georgia/concerns/revisionable.rb
georgia-0.7.4 app/models/georgia/concerns/revisionable.rb
georgia-0.7.3 app/models/georgia/concerns/revisionable.rb
georgia-0.7.2 app/models/georgia/concerns/revisionable.rb
georgia-0.7.1 app/models/georgia/concerns/revisionable.rb
georgia-0.7.0 app/models/georgia/concerns/revisionable.rb