Class: CurationConcerns::WorkShowPresenter
- Inherits:
-
Object
- Object
- CurationConcerns::WorkShowPresenter
- Includes:
- ModelProxy, PresentsAttributes
- Defined in:
- app/presenters/curation_concerns/work_show_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
- #export_as_jsonld ⇒ Object
- #export_as_nt ⇒ Object
- #export_as_ttl ⇒ Object
-
#initialize(solr_document, current_ability, request = nil) ⇒ WorkShowPresenter
constructor
A new instance of WorkShowPresenter.
- #inspect_work ⇒ Object
- #link_name ⇒ Object
-
#member_of_collection_presenters ⇒ Array<CollectionPresenter>
Get presenters for the collections this work is a member of via the member_of_collections association.
- #page_title ⇒ Object
-
#representative_presenter ⇒ Object
FileSetPresenter presenter for the representative FileSets.
- #workflow ⇒ Object
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) ⇒ WorkShowPresenter
Returns a new instance of WorkShowPresenter.
18 19 20 21 22 |
# File 'app/presenters/curation_concerns/work_show_presenter.rb', line 18 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.
5 6 7 |
# File 'app/presenters/curation_concerns/work_show_presenter.rb', line 5 def current_ability @current_ability end |
#request ⇒ Object
Returns the value of attribute request.
5 6 7 |
# File 'app/presenters/curation_concerns/work_show_presenter.rb', line 5 def request @request end |
#solr_document ⇒ Object
Returns the value of attribute solr_document.
5 6 7 |
# File 'app/presenters/curation_concerns/work_show_presenter.rb', line 5 def solr_document @solr_document end |
Instance Method Details
#export_as_jsonld ⇒ Object
75 76 77 |
# File 'app/presenters/curation_concerns/work_show_presenter.rb', line 75 def export_as_jsonld graph.dump(:jsonld, standard_prefixes: true) end |
#export_as_nt ⇒ Object
71 72 73 |
# File 'app/presenters/curation_concerns/work_show_presenter.rb', line 71 def export_as_nt graph.dump(:ntriples) end |
#export_as_ttl ⇒ Object
79 80 81 |
# File 'app/presenters/curation_concerns/work_show_presenter.rb', line 79 def export_as_ttl graph.dump(:ttl) end |
#inspect_work ⇒ Object
42 43 44 |
# File 'app/presenters/curation_concerns/work_show_presenter.rb', line 42 def inspect_work @inspect_workflow ||= InspectWorkPresenter.new(solr_document, current_ability) end |
#link_name ⇒ Object
67 68 69 |
# File 'app/presenters/curation_concerns/work_show_presenter.rb', line 67 def link_name current_ability.can?(:read, id) ? to_s : 'File' end |
#member_of_collection_presenters ⇒ Array<CollectionPresenter>
Get presenters for the collections this work is a member of via the member_of_collections association.
62 63 64 65 |
# File 'app/presenters/curation_concerns/work_show_presenter.rb', line 62 def member_of_collection_presenters PresenterFactory.build_presenters(member_of_collection_ids, collection_presenter_class, *presenter_factory_arguments) end |
#page_title ⇒ Object
24 25 26 |
# File 'app/presenters/curation_concerns/work_show_presenter.rb', line 24 def page_title title.first end |
#representative_presenter ⇒ Object
Returns FileSetPresenter presenter for the representative FileSets.
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/presenters/curation_concerns/work_show_presenter.rb', line 47 def representative_presenter return nil if representative_id.blank? @representative_presenter ||= begin result = member_presenters([representative_id]).first if result.respond_to?(:representative_presenter) result.representative_presenter else result end end end |
#workflow ⇒ Object
38 39 40 |
# File 'app/presenters/curation_concerns/work_show_presenter.rb', line 38 def workflow @workflow ||= WorkflowPresenter.new(solr_document, current_ability) end |