Sha256: d8322d79d96f3354b167b17216ef2a745ea652bfd7179237ef1beaa2c8e794fd

Contents?: true

Size: 657 Bytes

Versions: 1

Compression:

Stored size: 657 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

    validates :versionable, presence: true

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

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

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