Class: Hyrax::FileSetPresenter
- Inherits:
-
Object
- Object
- Hyrax::FileSetPresenter
- Defined in:
- app/presenters/hyrax/file_set_presenter.rb
Instance Attribute Summary collapse
-
#current_ability ⇒ Object
Returns the value of attribute current_ability.
-
#request ⇒ Object
Returns the value of attribute request.
-
#solr_document ⇒ Object
Returns the value of attribute solr_document.
Instance Method Summary collapse
-
#editor? ⇒ Boolean
deprecated
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.
-
#event_class ⇒ Object
This overrides the method in WithEvents.
- #events(size = 100) ⇒ Object
-
#first_title ⇒ Object
The first title assertion.
- #fixity_check_status ⇒ Object
-
#initialize(solr_document, current_ability, request = nil) ⇒ FileSetPresenter
constructor
A new instance of FileSetPresenter.
- #license ⇒ Object
-
#link_name ⇒ Object
The link text when linking to the show page of this FileSet.
-
#page_title ⇒ Object
The title of the webpage that shows this FileSet.
-
#parent ⇒ WorkShowPresenter?
nil
if no parent can be found. - #single_use_links ⇒ Object
- #stats_path ⇒ Object
- #tweeter ⇒ Object
- #user_can_perform_any_action? ⇒ Boolean
- #workflow ⇒ Object
Methods included from DisplaysImage
Methods included from WithEvents
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.
15 16 17 18 19 |
# File 'app/presenters/hyrax/file_set_presenter.rb', line 15 def initialize(solr_document, current_ability, request = nil) @solr_document = solr_document @current_ability = current_ability @request = request end |
Instance Attribute Details
#current_ability ⇒ Object
Returns the value of attribute current_ability.
10 11 12 |
# File 'app/presenters/hyrax/file_set_presenter.rb', line 10 def current_ability @current_ability end |
#request ⇒ Object
Returns the value of attribute request.
10 11 12 |
# File 'app/presenters/hyrax/file_set_presenter.rb', line 10 def request @request end |
#solr_document ⇒ Object
Returns the value of attribute solr_document.
10 11 12 |
# File 'app/presenters/hyrax/file_set_presenter.rb', line 10 def solr_document @solr_document end |
Instance Method Details
#editor? ⇒ Boolean
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.
65 66 67 |
# File 'app/presenters/hyrax/file_set_presenter.rb', line 65 def editor? current_ability.can?(:edit, self) end |
#event_class ⇒ Object
This overrides the method in WithEvents
87 88 89 |
# File 'app/presenters/hyrax/file_set_presenter.rb', line 87 def event_class solr_document.to_model.model_name.name end |
#events(size = 100) ⇒ Object
82 83 84 |
# File 'app/presenters/hyrax/file_set_presenter.rb', line 82 def events(size = 100) super(size) end |
#first_title ⇒ Object
The first title assertion
51 52 53 |
# File 'app/presenters/hyrax/file_set_presenter.rb', line 51 def first_title title.first end |
#fixity_check_status ⇒ Object
91 92 93 |
# File 'app/presenters/hyrax/file_set_presenter.rb', line 91 def fixity_check_status Hyrax::FixityStatusPresenter.new(id).render_file_set_status end |
#license ⇒ Object
73 74 75 76 |
# File 'app/presenters/hyrax/file_set_presenter.rb', line 73 def license return if solr_document.license.nil? solr_document.license.first end |
#link_name ⇒ Object
The link text when linking to the show page of this FileSet
56 57 58 |
# File 'app/presenters/hyrax/file_set_presenter.rb', line 56 def link_name current_ability.can?(:read, id) ? first_title : 'File' end |
#page_title ⇒ Object
The title of the webpage that shows this FileSet.
46 47 48 |
# File 'app/presenters/hyrax/file_set_presenter.rb', line 46 def page_title "#{human_readable_type} | #{title.first} | ID: #{id} | #{I18n.t('hyrax.product_name')}" end |
#parent ⇒ WorkShowPresenter?
Returns nil
if no parent can be found.
97 98 99 |
# File 'app/presenters/hyrax/file_set_presenter.rb', line 97 def parent @parent_presenter ||= fetch_parent_presenter end |
#single_use_links ⇒ Object
41 42 43 |
# File 'app/presenters/hyrax/file_set_presenter.rb', line 41 def single_use_links @single_use_links ||= SingleUseLink.where(item_id: id).map { |link| link_presenter_class.new(link) } end |
#stats_path ⇒ Object
78 79 80 |
# File 'app/presenters/hyrax/file_set_presenter.rb', line 78 def stats_path Hyrax::Engine.routes.url_helpers.stats_file_path(self, locale: I18n.locale) end |
#tweeter ⇒ Object
69 70 71 |
# File 'app/presenters/hyrax/file_set_presenter.rb', line 69 def tweeter TwitterPresenter.twitter_handle_for(user_key: depositor) end |
#user_can_perform_any_action? ⇒ Boolean
101 102 103 104 |
# File 'app/presenters/hyrax/file_set_presenter.rb', line 101 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 |
#workflow ⇒ Object
37 38 39 |
# File 'app/presenters/hyrax/file_set_presenter.rb', line 37 def workflow nil end |