Sha256: 6a24b51f4fae0b2ce1a25195534183c00c8202c5394cc9e5bce2f6c2b3ebb749

Contents?: true

Size: 755 Bytes

Versions: 1

Compression:

Stored size: 755 Bytes

Contents

module ControlledVersioning
  class Version < ActiveRecord::Base
    belongs_to :versionable, polymorphic: true
    belongs_to :user
    has_many :version_attributes, as: :version
    has_many :version_children, as: :version

    scope :pending, -> { where(pending: true) }
    scope :accepted, -> { where(accepted: true) }
    scope :declined, -> { where(declined: true) }

    def accept
      if pending?
        Revision::Publisher.new(self).accept_revision unless initial?
        update_attributes(pending: false, accepted: true)
      end
    end

    def decline
      update_attributes(pending: false, declined: true) if pending?
    end

    def revisions
      ChangeTracker.new(self)
    end

    def is_a_child?
      false
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
controlled_versioning-0.9.2 app/models/controlled_versioning/version.rb