Class: Hyrax::WorkQueryService
- Inherits:
-
Object
- Object
- Hyrax::WorkQueryService
- Defined in:
- app/services/hyrax/work_query_service.rb
Overview
Note:
This was extracted from the ProxyDepositRequest, which was coordinating lots of effort. It was also an ActiveRecord object that required lots of Fedora/Solr interactions.
Responsible for retrieving information based on the given work.
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#work_relation ⇒ Object
readonly
Returns the value of attribute work_relation.
Instance Method Summary collapse
-
#deleted_work? ⇒ Boolean
If the work has been deleted.
-
#initialize(id:, work_relation: default_work_relation) ⇒ WorkQueryService
constructor
A new instance of WorkQueryService.
- #to_s ⇒ Object
- #work ⇒ Object
Constructor Details
#initialize(id:, work_relation: default_work_relation) ⇒ WorkQueryService
Returns a new instance of WorkQueryService.
14 15 16 17 |
# File 'app/services/hyrax/work_query_service.rb', line 14 def initialize(id:, work_relation: default_work_relation) @id = id @work_relation = work_relation end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
18 19 20 |
# File 'app/services/hyrax/work_query_service.rb', line 18 def id @id end |
#work_relation ⇒ Object (readonly)
Returns the value of attribute work_relation.
18 19 20 |
# File 'app/services/hyrax/work_query_service.rb', line 18 def work_relation @work_relation end |
Instance Method Details
#deleted_work? ⇒ Boolean
Returns if the work has been deleted.
29 30 31 |
# File 'app/services/hyrax/work_query_service.rb', line 29 def deleted_work? !work_relation.exists?(id) end |
#to_s ⇒ Object
37 38 39 40 41 42 43 |
# File 'app/services/hyrax/work_query_service.rb', line 37 def to_s if deleted_work? 'work not found' else solr_doc.to_s end end |
#work ⇒ Object
33 34 35 |
# File 'app/services/hyrax/work_query_service.rb', line 33 def work @work ||= work_relation.find(id) end |