Class: Hyrax::FileSetPresenter

Inherits:
Object
  • Object
show all
Includes:
CharacterizationBehavior, DisplaysImage, DisplaysTranscripts, MissingMethodBehavior, ModelProxy, PresentsAttributes, WithEvents
Defined in:
app/presenters/hyrax/file_set_presenter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DisplaysTranscripts

#language_code, #transcript_url, #transcripts

Methods included from DisplaysImage

#display_image

Methods included from WithEvents

#log_event, #stream

Methods included from CharacterizationBehavior

#additional_characterization_metadata, #characterization_metadata, #characterized?, #label_for_term, #primary_characterization_values, #secondary_characterization_values

Methods included from PresentsAttributes

#attribute_to_html, #display_microdata?, #microdata_type_to_html, #permission_badge, #permission_badge_class

Methods included from ModelProxy

#persisted?, #to_model, #valid_child_concerns

Constructor Details

#initialize(solr_document, current_ability, request = nil) ⇒ FileSetPresenter

Returns a new instance of FileSetPresenter.

Parameters:

  • solr_document (SolrDocument)
  • current_ability (Ability)
  • request (ActionDispatch::Request) (defaults to: nil)

    the http request context



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

def initialize(solr_document, current_ability, request = nil)
  @solr_document = solr_document
  @current_ability = current_ability
  @request = request
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Hyrax::MissingMethodBehavior

Instance Attribute Details

#current_abilityObject

Returns the value of attribute current_ability.



12
13
14
# File 'app/presenters/hyrax/file_set_presenter.rb', line 12

def current_ability
  @current_ability
end

#requestObject

Returns the value of attribute request.



12
13
14
# File 'app/presenters/hyrax/file_set_presenter.rb', line 12

def request
  @request
end

#solr_documentObject

Returns the value of attribute solr_document.



12
13
14
# File 'app/presenters/hyrax/file_set_presenter.rb', line 12

def solr_document
  @solr_document
end

Instance Method Details

#editor?Boolean

Deprecated.

use ::Ability.can?(:edit, presenter). Hyrax views calling presenter #editor methods will continue to call them until Hyrax 4.0.0. The deprecation time horizon for the presenter methods themselves is 5.0.0.

Returns:

  • (Boolean)


58
59
60
# File 'app/presenters/hyrax/file_set_presenter.rb', line 58

def editor?
  current_ability.can?(:edit, self)
end

#event_classObject

This overrides the method in WithEvents



80
81
82
# File 'app/presenters/hyrax/file_set_presenter.rb', line 80

def event_class
  solr_document.to_model.model_name.name
end

#events(size = 100) ⇒ Object



75
76
77
# File 'app/presenters/hyrax/file_set_presenter.rb', line 75

def events(size = 100)
  super(size)
end

#first_titleObject

The first title assertion



44
45
46
# File 'app/presenters/hyrax/file_set_presenter.rb', line 44

def first_title
  title.first
end

#fixity_check_statusObject



84
85
86
# File 'app/presenters/hyrax/file_set_presenter.rb', line 84

def fixity_check_status
  Hyrax::FixityStatusPresenter.new(id).render_file_set_status
end

#licenseObject



66
67
68
69
# File 'app/presenters/hyrax/file_set_presenter.rb', line 66

def license
  return if solr_document.license.nil?
  solr_document.license.first
end

The link text when linking to the show page of this FileSet



49
50
51
# File 'app/presenters/hyrax/file_set_presenter.rb', line 49

def link_name
  current_ability.can?(:read, id) ? first_title : 'File'
end

#modelObject



30
31
32
# File 'app/presenters/hyrax/file_set_presenter.rb', line 30

def model
  solr_document.to_model
end

#page_titleObject

The title of the webpage that shows this FileSet.



39
40
41
# File 'app/presenters/hyrax/file_set_presenter.rb', line 39

def page_title
  "#{human_readable_type} | #{title.first} | ID: #{id} | #{I18n.t('hyrax.product_name')}"
end

#parentWorkShowPresenter?

Returns nil if no parent can be found.

Returns:



90
91
92
# File 'app/presenters/hyrax/file_set_presenter.rb', line 90

def parent
  @parent_presenter ||= fetch_parent_presenter
end

#show_partialsArray<String>

Returns:

  • (Array<String>)


101
102
103
# File 'app/presenters/hyrax/file_set_presenter.rb', line 101

def show_partials
  %w[show_details metadata]
end


34
35
36
# File 'app/presenters/hyrax/file_set_presenter.rb', line 34

def single_use_links
  @single_use_links ||= SingleUseLink.where(item_id: id).map { |link| link_presenter_class.new(link) }
end

#stats_pathObject



71
72
73
# File 'app/presenters/hyrax/file_set_presenter.rb', line 71

def stats_path
  Hyrax::Engine.routes.url_helpers.stats_file_path(self, locale: I18n.locale)
end

#tweeterObject



62
63
64
# File 'app/presenters/hyrax/file_set_presenter.rb', line 62

def tweeter
  TwitterPresenter.twitter_handle_for(user_key: depositor)
end

#user_can_perform_any_action?Boolean

Returns:

  • (Boolean)


94
95
96
97
# File 'app/presenters/hyrax/file_set_presenter.rb', line 94

def user_can_perform_any_action?
  Deprecation.warn("We're removing Hyrax::FileSetPresenter.user_can_perform_any_action? in Hyrax 4.0.0; Instead use can? in view contexts.")
  current_ability.can?(:edit, id) || current_ability.can?(:destroy, id) || current_ability.can?(:download, id)
end

#workflowObject



26
27
28
# File 'app/presenters/hyrax/file_set_presenter.rb', line 26

def workflow
  nil
end