Sha256: c13a222a21d0d0b57036c919a225119815714b6f5f9c7810d00e5a01d7044d8f

Contents?: true

Size: 717 Bytes

Versions: 43

Compression:

Stored size: 717 Bytes

Contents

module Ddr
  module Auth
    class AliasAbilityDefinitions < AbilityDefinitions

      FILE_REQUIRES_DOWNLOAD = %i( content extracted_text )
      DEFAULT_FILE_PERMISSION = :read

      DOWNLOAD_ALIASES = Ddr::Resource::FILE_FIELDS.each_with_object({}) do |field, memo|
        action = [ :download, field ].join('_').to_sym # e.g., :download_content
        memo[action] = FILE_REQUIRES_DOWNLOAD.include?(field) ? :download : DEFAULT_FILE_PERMISSION
      end

      def call
        alias_action :upload, to: :replace
        alias_action :add_attachment, to: :add_children
        DOWNLOAD_ALIASES.each do |action, permission|
          alias_action action, to: permission
        end
      end

    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
ddr-core-1.17.0 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.16.0 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.15.0 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.14.0 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.13.2 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.13.1 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.13.0 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.12.2 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.12.1 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.12.0 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.11.0 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.10.0 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.9.0 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.8.0 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.7.0 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.6.6 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.6.5 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.6.4 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.6.3 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.6.2 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb