Sha256: df9f41bf7eca67b1d276b513e86d72ff01eea806b24aa3754bcf332c1d046852

Contents?: true

Size: 724 Bytes

Versions: 1

Compression:

Stored size: 724 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 changes
      ChangeTracker.new(self).get_changes
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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