Class: Labimotion::ReleaseTemplateDoi
- Inherits:
-
Object
- Object
- Labimotion::ReleaseTemplateDoi
- Includes:
- TemplateDoiHelpers
- Defined in:
- lib/labimotion/usecases/release_template_doi.rb
Overview
Mints (publishes) a previously reserved DOI for a LabIMotion template via DataCite MDS. On success flips Doi#minted=true and stamps released_by/released_at on the template record.
Constant Summary
Constants included from TemplateDoiHelpers
TemplateDoiHelpers::GENERIC_ADMIN_KEY, TemplateDoiHelpers::KLASS_BY_TYPE
Instance Attribute Summary collapse
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
-
#doi ⇒ Object
readonly
Returns the value of attribute doi.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#record ⇒ Object
readonly
Returns the value of attribute record.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(record, current_user) ⇒ ReleaseTemplateDoi
constructor
A new instance of ReleaseTemplateDoi.
- #success? ⇒ Boolean
Methods included from TemplateDoiHelpers
authorized?, klass_type_for, new_version_available?, template_url
Constructor Details
#initialize(record, current_user) ⇒ ReleaseTemplateDoi
Returns a new instance of ReleaseTemplateDoi.
12 13 14 15 |
# File 'lib/labimotion/usecases/release_template_doi.rb', line 12 def initialize(record, current_user) @record = record @current_user = current_user end |
Instance Attribute Details
#current_user ⇒ Object (readonly)
Returns the value of attribute current_user.
10 11 12 |
# File 'lib/labimotion/usecases/release_template_doi.rb', line 10 def current_user @current_user end |
#doi ⇒ Object (readonly)
Returns the value of attribute doi.
10 11 12 |
# File 'lib/labimotion/usecases/release_template_doi.rb', line 10 def doi @doi end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
10 11 12 |
# File 'lib/labimotion/usecases/release_template_doi.rb', line 10 def error @error end |
#record ⇒ Object (readonly)
Returns the value of attribute record.
10 11 12 |
# File 'lib/labimotion/usecases/release_template_doi.rb', line 10 def record @record end |
Instance Method Details
#call ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/labimotion/usecases/release_template_doi.rb', line 17 def call return failure('record is required') if record.nil? return failure('unauthorized') unless TemplateDoiHelpers.(record, current_user) # Release the template's current (highest-sequence) DOI — the one a fresh # reserve created or returned. @doi = ::Doi.labimotion_latest_doi(record) return failure('doi not reserved') if @doi.nil? return self if @doi.minted return failure('publication metadata is incomplete') unless publish_at_datacite self end |
#success? ⇒ Boolean
33 34 35 |
# File 'lib/labimotion/usecases/release_template_doi.rb', line 33 def success? @error.nil? && @doi&.minted end |