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.6.2 lib/ddr/auth/ability_definitions/collection_ability_definitions.rb
ddr-models-2.6.1 lib/ddr/auth/ability_definitions/collection_ability_definitions.rb
ddr-models-2.6.0 lib/ddr/auth/ability_definitions/collection_ability_definitions.rb
ddr-models-2.6.0.rc4 lib/ddr/auth/ability_definitions/collection_ability_definitions.rb
ddr-models-2.6.0.rc3 lib/ddr/auth/ability_definitions/collection_ability_definitions.rb
ddr-models-2.6.0.rc2 lib/ddr/auth/ability_definitions/collection_ability_definitions.rb
ddr-models-2.6.0.rc1 lib/ddr/auth/ability_definitions/collection_ability_definitions.rb
ddr-models-2.5.3 lib/ddr/auth/ability_definitions/collection_ability_definitions.rb
ddr-models-2.5.2 lib/ddr/auth/ability_definitions/collection_ability_definitions.rb
ddr-models-2.5.1 lib/ddr/auth/ability_definitions/collection_ability_definitions.rb
ddr-models-2.5.0 lib/ddr/auth/ability_definitions/collection_ability_definitions.rb
ddr-models-2.5.0.rc1 lib/ddr/auth/ability_definitions/collection_ability_definitions.rb
ddr-models-2.4.16 lib/ddr/auth/ability_definitions/collection_ability_definitions.rb
ddr-models-2.4.15 lib/ddr/auth/ability_definitions/collection_ability_definitions.rb