Class: Eco::API::UseCases::GraphQL::Samples::Pages::Template::Base
- Inherits:
-
Base
- Object
- Loaders::Base
- Common::Loaders::CaseBase
- Common::Loaders::UseCase
- Base
- Eco::API::UseCases::GraphQL::Samples::Pages::Template::Base
- Defined in:
- lib/eco/api/usecases/graphql/samples/pages/template/base.rb
Overview
Build-from-scratch template (workflow) construction use case.
A subclass declares the desired template structure in #declare(emitter) using the
CommandEmitter DSL; the base turns it into an ordered command batch and applies it via
graphql.template.create / update (executeWorkflowCommands). simulate? previews the batch
without writing. The emitted batch (#desired_commands) is unit-testable with no live client.
class Custom::UseCase::BuildIncidentTemplate < Samples::Pages::Template::Base name 'build-incident-template'
def declare(t)
t.stage(name: 'Report', ordering: 0) do |stage|
stage.section(layout: 'content') do |section|
section.field(label: 'Description', field_type: 'plain_text')
end
end
end
end
Instance Attribute Summary
Attributes included from Lib::ErrorHandling
Attributes included from Language::AuxiliarLogger
Instance Method Summary collapse
-
#declare(_emitter) ⇒ Object
Declare the desired template structure onto the given CommandEmitter.
-
#desired_commands ⇒ Object
The ordered command batch this template would apply.
- #process ⇒ Object
Methods inherited from Base
Methods included from Language::Methods::CallDetector
Methods included from Language::AuxiliarLogger
Methods inherited from Common::Loaders::UseCase
#cli_apply!, #initialize, #main
Methods included from Common::Loaders::UseCase::CliIdentify
Methods included from Common::Loaders::UseCase::TargetModel
Methods included from Common::Loaders::UseCase::Type
Methods inherited from Common::Loaders::CaseBase
#name, name_only_once!, original_name
Constructor Details
This class inherits a constructor from Eco::API::Common::Loaders::UseCase
Instance Method Details
#declare(_emitter) ⇒ Object
Declare the desired template structure onto the given CommandEmitter.
38 39 40 |
# File 'lib/eco/api/usecases/graphql/samples/pages/template/base.rb', line 38 def declare(_emitter) raise NotImplementedError, "Implement #declare(emitter) in #{self.class}" end |
#desired_commands ⇒ Object
The ordered command batch this template would apply. Pure — no client needed.
43 44 45 46 47 |
# File 'lib/eco/api/usecases/graphql/samples/pages/template/base.rb', line 43 def desired_commands emitter = CommandEmitter.new declare(emitter) emitter.commands end |
#process ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/eco/api/usecases/graphql/samples/pages/template/base.rb', line 26 def process commands = desired_commands if simulate? log(:info) { (commands) } return nil end apply(commands) end |