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.6.1 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.6.0 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.5.5 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.5.4 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.5.2 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.5.3 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.5.1 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.4.4 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.4.3 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.4.2 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.4.0 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.3.0 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.2.0 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.2.0.rc3 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.2.0.rc2 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.2.0.rc1 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.1.2 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.1.1 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.1.0 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb
ddr-core-1.0.0 lib/ddr/auth/ability_definitions/alias_ability_definitions.rb