Sha256: 652afa99b8de7417c2228e001b2a6d7a478895a839f0100ddaa848a4f391b611
Contents?: true
Size: 1022 Bytes
Versions: 25
Compression:
Stored size: 1022 Bytes
Contents
# frozen_string_literal: true module Hyrax class SingleUseLinkPresenter include ActionView::Helpers::TranslationHelper attr_reader :link delegate :download_key, :expired?, :to_param, to: :link # @param link [SingleUseLink] def initialize(link) @link = link end def human_readable_expiration if hours < 1 t('hyrax.single_use_links.expiration.lesser_time') else t('hyrax.single_use_links.expiration.time', value: hours) end end def short_key link.download_key.first(6) end def link_type if download? t('hyrax.single_use_links.download.type') else t('hyrax.single_use_links.show.type') end end def url_helper if download? "download_single_use_link_url" else "show_single_use_link_url" end end private def download? link.path =~ /downloads/ end def hours (link.expires - Time.zone.now).to_i / 3600 end end end
Version data entries
25 entries across 25 versions & 1 rubygems