Sha256: 263a23f53277dfd14293ddf4b1cb02c7ac5a8b0866faf147df9b7d03d56eccf5

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

require 'active_support/concern'

module Georgia
  module Concerns
    module PublishingPolicy
      extend ActiveSupport::Concern

      included do

        def request_review?
          publishing_user_permissions(:request_review).include?(true)
        end

        def draft?
          publishing_user_permissions(:draft_changes).include?(true)
        end

        def approve?
          publishing_user_permissions(:approve_changes).include?(true)
        end

        def decline?
          publishing_user_permissions(:decline_changes).include?(true)
        end

        def restore?
          publishing_user_permissions(:restore_changes).include?(true)
        end

        def publish?
          publishing_user_permissions(:publish_pages).include?(true)
        end

        def unpublish?
          publishing_user_permissions(:unpublish_pages).include?(true)
        end

        private

        def publishing_permissions
          Georgia.permissions[:publishing]
        end

        def publishing_user_permissions action
          user_permissions(publishing_permissions, action)
        end

      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
georgia-0.8.0 app/policies/georgia/concerns/publishing_policy.rb