Class: Eco::API::UseCases::GraphQL::Samples::Pages::Template::Deploy::Applier
- Inherits:
-
Object
- Object
- Eco::API::UseCases::GraphQL::Samples::Pages::Template::Deploy::Applier
- Defined in:
- lib/eco/api/usecases/graphql/samples/pages/template/deploy/applier.rb
Overview
Thin, offline-safe wrapper around a gem Diff::Deploy plan.
The gem's Diff::Deploy is INERT until execute! is called with an explicit executor — this
applier keeps that safety and adds a dry-run default: nothing hits the API unless the caller
opts in with commit: true AND supplies a live executor. The dry-run path records the batch it
WOULD send (so the pre/post-diff and the specs can inspect it) and never calls the executor.
An "executor" is anything responding to execute_workflow_commands(model_or_id, commands:) —
in production the gem's graphql.page / Builder::Template update facade. For dry-run + specs a
capturing stand-in is enough; see Deploy::RecordingExecutor.
plan = Ecoportal::API::GraphQL::Diff::Deploy.from_versions(before, after, target_doc: prod) applier = Applier.new(plan, target: prod_template) outcome = applier.apply # dry-run: records commands, no API call outcome = applier.apply(commit: true, executor: graphql.page) # live apply
outcome.committed? # => false for dry-run outcome.commands # => the ordered batch that was (or would be) sent outcome.unsupported # => [Change, ...] the plan could not synthesise (needs a human)
Defined Under Namespace
Classes: Outcome, TargetBoundExecutor
Instance Attribute Summary collapse
-
#plan ⇒ Object
readonly
Returns the value of attribute plan.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
-
#apply(commit: false, executor: nil, allow_partial: false) ⇒ Outcome
Apply the plan's command batch.
-
#commands ⇒ Object
The ordered command batch (delegates to the gem plan).
- #fully_supported? ⇒ Boolean
-
#initialize(plan, target: nil) ⇒ Applier
constructor
A new instance of Applier.
-
#unsupported ⇒ Object
Changes the gem plan could not synthesise — surfaced so a human gates the deploy.
Constructor Details
#initialize(plan, target: nil) ⇒ Applier
Returns a new instance of Applier.
53 54 55 56 |
# File 'lib/eco/api/usecases/graphql/samples/pages/template/deploy/applier.rb', line 53 def initialize(plan, target: nil) @plan = plan @target = target end |
Instance Attribute Details
#plan ⇒ Object (readonly)
Returns the value of attribute plan.
48 49 50 |
# File 'lib/eco/api/usecases/graphql/samples/pages/template/deploy/applier.rb', line 48 def plan @plan end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
48 49 50 |
# File 'lib/eco/api/usecases/graphql/samples/pages/template/deploy/applier.rb', line 48 def target @target end |
Instance Method Details
#apply(commit: false, executor: nil, allow_partial: false) ⇒ Outcome
Apply the plan's command batch.
65 66 67 68 69 70 71 |
# File 'lib/eco/api/usecases/graphql/samples/pages/template/deploy/applier.rb', line 65 def apply(commit: false, executor: nil, allow_partial: false) return blocked_outcome unless deployable?(allow_partial) return dry_run_outcome unless commit commit_outcome(executor, allow_partial: allow_partial) end |
#commands ⇒ Object
The ordered command batch (delegates to the gem plan).
74 75 76 |
# File 'lib/eco/api/usecases/graphql/samples/pages/template/deploy/applier.rb', line 74 def commands plan.commands end |
#fully_supported? ⇒ Boolean
83 84 85 |
# File 'lib/eco/api/usecases/graphql/samples/pages/template/deploy/applier.rb', line 83 def fully_supported? plan.fully_supported? end |
#unsupported ⇒ Object
Changes the gem plan could not synthesise — surfaced so a human gates the deploy.
79 80 81 |
# File 'lib/eco/api/usecases/graphql/samples/pages/template/deploy/applier.rb', line 79 def unsupported plan.unsupported end |