Class: Hyrax::FileSetPresenter
- Inherits:
-
Object
- Object
- Hyrax::FileSetPresenter
- Includes:
- CharacterizationBehavior, ModelProxy, PresentsAttributes, WithEvents
- 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
- #audit_service ⇒ Object
- #audit_status ⇒ Object
- #editor? ⇒ Boolean
-
#event_class ⇒ Object
This overrides the method in WithEvents.
- #events(size = 100) ⇒ Object
-
#first_title ⇒ Object
The first title assertion.
-
#initialize(solr_document, current_ability, request = nil) ⇒ FileSetPresenter
constructor
A new instance of FileSetPresenter.
-
#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 ⇒ Object
- #rights ⇒ Object
- #single_use_links ⇒ Object
- #stats_path ⇒ Object
- #tweeter ⇒ Object
Methods included from WithEvents
#event_store, #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, #to_partial_path
Constructor Details
#initialize(solr_document, current_ability, request = nil) ⇒ FileSetPresenter
Returns a new instance of FileSetPresenter.
13 14 15 16 17 |
# File 'app/presenters/hyrax/file_set_presenter.rb', line 13 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.
8 9 10 |
# File 'app/presenters/hyrax/file_set_presenter.rb', line 8 def current_ability @current_ability end |
#request ⇒ Object
Returns the value of attribute request.
8 9 10 |
# File 'app/presenters/hyrax/file_set_presenter.rb', line 8 def request @request end |
#solr_document ⇒ Object
Returns the value of attribute solr_document.
8 9 10 |
# File 'app/presenters/hyrax/file_set_presenter.rb', line 8 def solr_document @solr_document end |
Instance Method Details
#audit_service ⇒ Object
97 98 99 |
# File 'app/presenters/hyrax/file_set_presenter.rb', line 97 def audit_service @audit_service ||= Hyrax::FileSetAuditService.new(id) end |
#audit_status ⇒ Object
84 85 86 |
# File 'app/presenters/hyrax/file_set_presenter.rb', line 84 def audit_status audit_service.logged_audit_status end |
#editor? ⇒ Boolean
53 54 55 |
# File 'app/presenters/hyrax/file_set_presenter.rb', line 53 def editor? current_ability.can?(:edit, solr_document) end |
#event_class ⇒ Object
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_title ⇒ Object
The first title assertion
44 45 46 |
# File 'app/presenters/hyrax/file_set_presenter.rb', line 44 def first_title title.first end |
#link_name ⇒ Object
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 |
#page_title ⇒ Object
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 first_title end |
#parent ⇒ Object
88 89 90 91 92 93 94 95 |
# File 'app/presenters/hyrax/file_set_presenter.rb', line 88 def parent ids = ActiveFedora::SolrService.query("{!field f=member_ids_ssim}#{id}", fl: ActiveFedora.id_field) .map { |x| x.fetch(ActiveFedora.id_field) } @parent_presenter ||= Hyrax::PresenterFactory.build_presenters(ids, WorkShowPresenter, current_ability).first end |
#rights ⇒ Object
66 67 68 69 |
# File 'app/presenters/hyrax/file_set_presenter.rb', line 66 def rights return if solr_document.rights.nil? solr_document.rights.first end |
#single_use_links ⇒ Object
34 35 36 |
# File 'app/presenters/hyrax/file_set_presenter.rb', line 34 def single_use_links @single_use_links ||= SingleUseLink.where(itemId: id).map { |link| link_presenter_class.new(link) } end |
#stats_path ⇒ Object
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) end |
#tweeter ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'app/presenters/hyrax/file_set_presenter.rb', line 57 def tweeter user = ::User.find_by_user_key(depositor) if user.try(:twitter_handle).present? "@#{user.twitter_handle}" else I18n.translate('hyrax.product_twitter_handle') end end |