Class: CurationConcerns::WorkShowPresenter

Inherits:
Object
  • Object
show all
Includes:
ModelProxy, PresentsAttributes
Defined in:
app/presenters/curation_concerns/work_show_presenter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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.

Parameters:

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

    the http request context



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_abilityObject

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

#requestObject

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_documentObject

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_jsonldObject



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_ntObject



71
72
73
# File 'app/presenters/curation_concerns/work_show_presenter.rb', line 71

def export_as_nt
  graph.dump(:ntriples)
end

#export_as_ttlObject



79
80
81
# File 'app/presenters/curation_concerns/work_show_presenter.rb', line 79

def export_as_ttl
  graph.dump(:ttl)
end

#inspect_workObject



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


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_presentersArray<CollectionPresenter>

Get presenters for the collections this work is a member of via the member_of_collections association.

Returns:



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_titleObject



24
25
26
# File 'app/presenters/curation_concerns/work_show_presenter.rb', line 24

def page_title
  title.first
end

#representative_presenterObject

Returns FileSetPresenter presenter for the representative FileSets.

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

#workflowObject



38
39
40
# File 'app/presenters/curation_concerns/work_show_presenter.rb', line 38

def workflow
  @workflow ||= WorkflowPresenter.new(solr_document, current_ability)
end