Class: Dor::Workflow::Client::LifecycleRoutes
- Inherits:
-
Object
- Object
- Dor::Workflow::Client::LifecycleRoutes
- Defined in:
- lib/dor/workflow/client/lifecycle_routes.rb
Overview
Makes requests relating to a lifecycle
Instance Method Summary collapse
-
#active_lifecycle(druid:, milestone_name:, version:) ⇒ Time
Returns the Date for a requested milestone ONLY for the current version.
-
#initialize(requestor:) ⇒ LifecycleRoutes
constructor
A new instance of LifecycleRoutes.
-
#lifecycle(druid:, milestone_name:, version: nil, active_only: false) ⇒ Time
Returns the Date for a requested milestone from workflow lifecycle.
- #milestones(druid:) ⇒ Array<Hash>
Constructor Details
#initialize(requestor:) ⇒ LifecycleRoutes
Returns a new instance of LifecycleRoutes.
8 9 10 |
# File 'lib/dor/workflow/client/lifecycle_routes.rb', line 8 def initialize(requestor:) @requestor = requestor end |
Instance Method Details
#active_lifecycle(druid:, milestone_name:, version:) ⇒ Time
Returns the Date for a requested milestone ONLY for the current version. This is slow as the workflow server will query dor-services-app for the version. A better approach is #lifecycle with the version tag.
30 31 32 |
# File 'lib/dor/workflow/client/lifecycle_routes.rb', line 30 def active_lifecycle(druid:, milestone_name:, version:) lifecycle(druid: druid, milestone_name: milestone_name, version: version, active_only: true) end |
#lifecycle(druid:, milestone_name:, version: nil, active_only: false) ⇒ Time
Returns the Date for a requested milestone from workflow lifecycle
19 20 21 |
# File 'lib/dor/workflow/client/lifecycle_routes.rb', line 19 def lifecycle(druid:, milestone_name:, version: nil, active_only: false) filter_milestone(query_lifecycle(druid, version: version, active_only: active_only), milestone_name) end |
#milestones(druid:) ⇒ Array<Hash>
35 36 37 38 39 40 |
# File 'lib/dor/workflow/client/lifecycle_routes.rb', line 35 def milestones(druid:) doc = query_lifecycle(druid, active_only: false) doc.xpath('//lifecycle/milestone').collect do |node| { milestone: node.text, at: Time.parse(node['date']), version: node['version'] } end end |