Class: Hyrax::SingleUseLinkPresenter

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::TranslationHelper
Defined in:
app/presenters/hyrax/single_use_link_presenter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(link) ⇒ SingleUseLinkPresenter

Returns a new instance of SingleUseLinkPresenter.

Parameters:


11
12
13
# File 'app/presenters/hyrax/single_use_link_presenter.rb', line 11

def initialize(link)
  @link = link
end

Instance Attribute Details

Returns the value of attribute link


6
7
8
# File 'app/presenters/hyrax/single_use_link_presenter.rb', line 6

def link
  @link
end

Instance Method Details

#human_readable_expirationObject


15
16
17
18
19
20
21
# File 'app/presenters/hyrax/single_use_link_presenter.rb', line 15

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

27
28
29
30
31
32
33
# File 'app/presenters/hyrax/single_use_link_presenter.rb', line 27

def link_type
  if download?
    t('hyrax.single_use_links.download.type')
  else
    t('hyrax.single_use_links.show.type')
  end
end

#short_keyObject


23
24
25
# File 'app/presenters/hyrax/single_use_link_presenter.rb', line 23

def short_key
  link.download_key.first(6)
end

#url_helperObject


35
36
37
38
39
40
41
# File 'app/presenters/hyrax/single_use_link_presenter.rb', line 35

def url_helper
  if download?
    "download_single_use_link_url"
  else
    "show_single_use_link_url"
  end
end