Sha256: 59292a8d5d293f583230c44431b6fe1865c3f76b5a4fd99429a8202ff018425e

Contents?: true

Size: 603 Bytes

Versions: 34

Compression:

Stored size: 603 Bytes

Contents

module Ddr
  module Auth
    class CollectionAbilityDefinitions < AbilityDefinitions

      def call
        if member_of? Ddr::Auth.collection_creators_group
          can :create, ::Collection
        end
        can :export, ::Collection do |obj|
          has_policy_permission?(obj, Permissions::READ)
        end
      end

      private

      def policy_permissions(obj)
        obj.roles
          .in_policy_scope
          .agent(agents)
          .permissions
      end

      def has_policy_permission?(obj, perm)
        policy_permissions(obj).include?(perm)
      end

    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
ddr-models-2.11.0 lib/ddr/auth/ability_definitions/collection_ability_definitions.rb
ddr-models-2.10.2 lib/ddr/auth/ability_definitions/collection_ability_definitions.rb
ddr-models-2.10.1 lib/ddr/auth/ability_definitions/collection_ability_definitions.rb
ddr-models-2.10.0 lib/ddr/auth/ability_definitions/collection_ability_definitions.rb
ddr-models-2.10.0.rc2 lib/ddr/auth/ability_definitions/collection_ability_definitions.rb
ddr-models-2.10.0.rc1 lib/ddr/auth/ability_definitions/collection_ability_definitions.rb
ddr-models-2.9.2 lib/ddr/auth/ability_definitions/collection_ability_definitions.rb
ddr-models-2.9.1 lib/ddr/auth/ability_definitions/collection_ability_definitions.rb
ddr-models-2.9.0 lib/ddr/auth/ability_definitions/collection_ability_definitions.rb
ddr-models-2.9.0.rc1 lib/ddr/auth/ability_definitions/collection_ability_definitions.rb
ddr-models-2.8.0 lib/ddr/auth/ability_definitions/collection_ability_definitions.rb
ddr-models-2.8.0.rc1 lib/ddr/auth/ability_definitions/collection_ability_definitions.rb
ddr-models-2.7.6 lib/ddr/auth/ability_definitions/collection_ability_definitions.rb
ddr-models-2.7.5 lib/ddr/auth/ability_definitions/collection_ability_definitions.rb
ddr-models-2.7.4 lib/ddr/auth/ability_definitions/collection_ability_definitions.rb
ddr-models-2.7.3 lib/ddr/auth/ability_definitions/collection_ability_definitions.rb
ddr-models-2.7.2 lib/ddr/auth/ability_definitions/collection_ability_definitions.rb
ddr-models-2.7.1 lib/ddr/auth/ability_definitions/collection_ability_definitions.rb
ddr-models-2.7.0 lib/ddr/auth/ability_definitions/collection_ability_definitions.rb
ddr-models-2.7.0.rc1 lib/ddr/auth/ability_definitions/collection_ability_definitions.rb