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
-
#collection_presenters ⇒ Array<CollectionPresenter>
Presenters for the collections that this work is a member of.
- #composite_presenter_class ⇒ Object
- #export_as_jsonld ⇒ Object
- #export_as_nt ⇒ Object
- #export_as_ttl ⇒ Object
-
#file_set_presenters ⇒ Array<FileSetPresenter>
Presenters for the orderd_members that are FileSets.
-
#initialize(solr_document, current_ability, request = nil) ⇒ WorkShowPresenter
constructor
A new instance of WorkShowPresenter.
- #link_name ⇒ Object
-
#member_presenters(ids = ordered_ids, presenter_class = composite_presenter_class) ⇒ Array<presenter_class>
Presenters for the ordered_members (not filtered by class).
- #page_title ⇒ Object
-
#representative_presenter ⇒ Object
FileSetPresenter presenter for the representative FileSets.
-
#work_presenters ⇒ Array<WorkShowPresenter>
Presenters for the ordered_members that are not FileSets.
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.
24 25 26 27 28 |
# File 'app/presenters/curation_concerns/work_show_presenter.rb', line 24 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
#collection_presenters ⇒ Array<CollectionPresenter>
Returns presenters for the collections that this work is a member of.
81 82 83 84 85 |
# File 'app/presenters/curation_concerns/work_show_presenter.rb', line 81 def collection_presenters PresenterFactory.build_presenters(in_collection_ids, collection_presenter_class, *presenter_factory_arguments) end |
#composite_presenter_class ⇒ Object
76 77 78 |
# File 'app/presenters/curation_concerns/work_show_presenter.rb', line 76 def composite_presenter_class CompositePresenterFactory.new(file_presenter_class, work_presenter_class, ordered_ids & file_set_ids) end |
#export_as_jsonld ⇒ Object
95 96 97 |
# File 'app/presenters/curation_concerns/work_show_presenter.rb', line 95 def export_as_jsonld graph.dump(:jsonld, standard_prefixes: true) end |
#export_as_nt ⇒ Object
91 92 93 |
# File 'app/presenters/curation_concerns/work_show_presenter.rb', line 91 def export_as_nt graph.dump(:ntriples) end |
#export_as_ttl ⇒ Object
99 100 101 |
# File 'app/presenters/curation_concerns/work_show_presenter.rb', line 99 def export_as_ttl graph.dump(:ttl) end |
#file_set_presenters ⇒ Array<FileSetPresenter>
Returns presenters for the orderd_members that are FileSets.
44 45 46 |
# File 'app/presenters/curation_concerns/work_show_presenter.rb', line 44 def file_set_presenters @file_set_presenters ||= member_presenters(ordered_ids & file_set_ids) end |
#link_name ⇒ Object
87 88 89 |
# File 'app/presenters/curation_concerns/work_show_presenter.rb', line 87 def link_name current_ability.can?(:read, id) ? to_s : 'File' end |
#member_presenters(ids = ordered_ids, presenter_class = composite_presenter_class) ⇒ Array<presenter_class>
Returns presenters for the ordered_members (not filtered by class).
70 71 72 73 74 |
# File 'app/presenters/curation_concerns/work_show_presenter.rb', line 70 def member_presenters(ids = ordered_ids, presenter_class = composite_presenter_class) PresenterFactory.build_presenters(ids, presenter_class, *presenter_factory_arguments) end |
#page_title ⇒ Object
30 31 32 |
# File 'app/presenters/curation_concerns/work_show_presenter.rb', line 30 def page_title title.first end |
#representative_presenter ⇒ Object
Returns FileSetPresenter presenter for the representative FileSets.
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/presenters/curation_concerns/work_show_presenter.rb', line 49 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 |
#work_presenters ⇒ Array<WorkShowPresenter>
Returns presenters for the ordered_members that are not FileSets.
63 64 65 |
# File 'app/presenters/curation_concerns/work_show_presenter.rb', line 63 def work_presenters @work_presenters ||= member_presenters(ordered_ids - file_set_ids, work_presenter_class) end |