class Ddr::Auth::DatastreamAbilityDefinitions

Constants

DATASTREAM_DOWNLOAD_ABILITIES

Maps datastream id to an ability required on the object to download the datastream.

Datastreams not listed cannot be downloaded, except of course by the :manage ability.

Public Instance Methods

call() click to toggle source
# File lib/ddr/auth/ability_definitions/datastream_ability_definitions.rb, line 18
def call
  can :download, ActiveFedora::File do |file|
    can_download_datastream?(_dsid(file), _pid(file))
  end
end

Private Instance Methods

_dsid(file) click to toggle source
# File lib/ddr/auth/ability_definitions/datastream_ability_definitions.rb, line 26
def _dsid(file)
  File.basename(file.id)
end
_pid(file) click to toggle source
# File lib/ddr/auth/ability_definitions/datastream_ability_definitions.rb, line 30
def _pid(file)
  File.dirname(file.id)
end
can_download_datastream?(dsid, pid) click to toggle source
# File lib/ddr/auth/ability_definitions/datastream_ability_definitions.rb, line 34
def can_download_datastream?(dsid, pid)
  can? DATASTREAM_DOWNLOAD_ABILITIES.fetch(dsid), pid
rescue KeyError
  false
end