Sha256: b2d8e4d88db5ba02970f215ac55ccf5240518763041992b732fa761171537051

Contents?: true

Size: 664 Bytes

Versions: 9

Compression:

Stored size: 664 Bytes

Contents

module Ddr
  module Auth
    class PublicationAbilityDefinitions < AbilityDefinitions

      # An object can't be published if it's already published or not publishable
      # It can't be unpublished if it's already unpublished
      # It can't be made nonpublishable if it's already nonpublishable
      def call
        cannot :publish, Ddr::Resource do |obj|
          obj.published? || !obj.publishable?
        end
        cannot :unpublish, Ddr::Resource do |obj|
          !obj.published? && !obj.nonpublishable?
        end
        cannot :make_nonpublishable, Ddr::Resource do |obj|
          obj.nonpublishable?
        end
      end

    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ddr-core-1.17.0 lib/ddr/auth/ability_definitions/publication_ability_definitions.rb
ddr-core-1.16.0 lib/ddr/auth/ability_definitions/publication_ability_definitions.rb
ddr-core-1.15.0 lib/ddr/auth/ability_definitions/publication_ability_definitions.rb
ddr-core-1.14.0 lib/ddr/auth/ability_definitions/publication_ability_definitions.rb
ddr-core-1.13.2 lib/ddr/auth/ability_definitions/publication_ability_definitions.rb
ddr-core-1.13.1 lib/ddr/auth/ability_definitions/publication_ability_definitions.rb
ddr-core-1.13.0 lib/ddr/auth/ability_definitions/publication_ability_definitions.rb
ddr-core-1.12.2 lib/ddr/auth/ability_definitions/publication_ability_definitions.rb
ddr-core-1.12.1 lib/ddr/auth/ability_definitions/publication_ability_definitions.rb