Sha256: b28f58a7199f0c9343f416f2bd9084ece383e28f3f68c683730d50bac871fe7f

Contents?: true

Size: 738 Bytes

Versions: 25

Compression:

Stored size: 738 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 published (must be unpublished 
      # first) or 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.published? || !obj.publishable?
        end
      end

    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
ddr-core-1.12.0 lib/ddr/auth/ability_definitions/publication_ability_definitions.rb
ddr-core-1.11.0 lib/ddr/auth/ability_definitions/publication_ability_definitions.rb
ddr-core-1.10.0 lib/ddr/auth/ability_definitions/publication_ability_definitions.rb
ddr-core-1.9.0 lib/ddr/auth/ability_definitions/publication_ability_definitions.rb
ddr-core-1.8.0 lib/ddr/auth/ability_definitions/publication_ability_definitions.rb
ddr-core-1.7.0 lib/ddr/auth/ability_definitions/publication_ability_definitions.rb
ddr-core-1.6.6 lib/ddr/auth/ability_definitions/publication_ability_definitions.rb
ddr-core-1.6.5 lib/ddr/auth/ability_definitions/publication_ability_definitions.rb
ddr-core-1.6.4 lib/ddr/auth/ability_definitions/publication_ability_definitions.rb
ddr-core-1.6.3 lib/ddr/auth/ability_definitions/publication_ability_definitions.rb
ddr-core-1.6.2 lib/ddr/auth/ability_definitions/publication_ability_definitions.rb
ddr-core-1.6.1 lib/ddr/auth/ability_definitions/publication_ability_definitions.rb
ddr-core-1.6.0 lib/ddr/auth/ability_definitions/publication_ability_definitions.rb
ddr-core-1.5.5 lib/ddr/auth/ability_definitions/publication_ability_definitions.rb
ddr-core-1.5.4 lib/ddr/auth/ability_definitions/publication_ability_definitions.rb
ddr-core-1.5.2 lib/ddr/auth/ability_definitions/publication_ability_definitions.rb
ddr-core-1.5.3 lib/ddr/auth/ability_definitions/publication_ability_definitions.rb
ddr-core-1.5.1 lib/ddr/auth/ability_definitions/publication_ability_definitions.rb
ddr-core-1.4.4 lib/ddr/auth/ability_definitions/publication_ability_definitions.rb
ddr-core-1.4.3 lib/ddr/auth/ability_definitions/publication_ability_definitions.rb