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.
13 14 15 16 |
# File 'app/services/hyrax/work_query_service.rb', line 13 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.
17 18 19 |
# File 'app/services/hyrax/work_query_service.rb', line 17 def id @id end |
#work_relation ⇒ Object (readonly)
Returns the value of attribute work_relation.
17 18 19 |
# File 'app/services/hyrax/work_query_service.rb', line 17 def work_relation @work_relation end |
Instance Method Details
#deleted_work? ⇒ Boolean
Returns if the work has been deleted.
28 29 30 |
# File 'app/services/hyrax/work_query_service.rb', line 28 def deleted_work? !work_relation.exists?(id) end |
#to_s ⇒ Object
36 37 38 39 40 41 42 |
# File 'app/services/hyrax/work_query_service.rb', line 36 def to_s if deleted_work? 'work not found' else solr_doc.to_s end end |
#work ⇒ Object
32 33 34 |
# File 'app/services/hyrax/work_query_service.rb', line 32 def work @work ||= work_relation.find(id) end |