Class: Igniter::Extensions::Contracts::Mcp::CreatorSession
- Inherits:
-
Object
- Object
- Igniter::Extensions::Contracts::Mcp::CreatorSession
- Defined in:
- lib/igniter/extensions/contracts/mcp/creator_session.rb
Constant Summary collapse
- ATTRIBUTES =
%i[ name kind namespace profile capabilities scope root mode pack target_profile ].freeze
Class Method Summary collapse
Instance Method Summary collapse
- #apply(**updates) ⇒ Object
-
#initialize(name: nil, kind: nil, namespace: "MyCompany::IgniterPacks", profile: nil, capabilities: nil, scope: nil, root: nil, mode: :skip_existing, pack: nil, target_profile: nil) ⇒ CreatorSession
constructor
A new instance of CreatorSession.
- #to_h ⇒ Object
- #wizard ⇒ Object
- #workflow_payload ⇒ Object
- #write_payload ⇒ Object
- #write_plan_payload ⇒ Object
Constructor Details
#initialize(name: nil, kind: nil, namespace: "MyCompany::IgniterPacks", profile: nil, capabilities: nil, scope: nil, root: nil, mode: :skip_existing, pack: nil, target_profile: nil) ⇒ CreatorSession
Returns a new instance of CreatorSession.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/igniter/extensions/contracts/mcp/creator_session.rb', line 23 def initialize(name: nil, kind: nil, namespace: "MyCompany::IgniterPacks", profile: nil, capabilities: nil, scope: nil, root: nil, mode: :skip_existing, pack: nil, target_profile: nil) @name = name @kind = kind @namespace = namespace @profile = profile @capabilities = capabilities @scope = scope @root = root @mode = mode @pack = pack @target_profile = target_profile freeze end |
Class Method Details
.from_h(payload, target_profile: nil) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/igniter/extensions/contracts/mcp/creator_session.rb', line 38 def self.from_h(payload, target_profile: nil) new( name: payload[:name] || payload["name"], kind: payload[:kind] || payload["kind"], namespace: payload[:namespace] || payload["namespace"] || "MyCompany::IgniterPacks", profile: payload[:profile] || payload["profile"], capabilities: payload[:capabilities] || payload["capabilities"], scope: payload[:scope] || payload["scope"], root: payload[:root] || payload["root"], mode: payload[:mode] || payload["mode"] || :skip_existing, pack: payload[:pack] || payload["pack"], target_profile: target_profile ) end |
Instance Method Details
#apply(**updates) ⇒ Object
53 54 55 56 57 |
# File 'lib/igniter/extensions/contracts/mcp/creator_session.rb', line 53 def apply(**updates) self.class.new( **ATTRIBUTES.to_h { |attribute| [attribute, updates.fetch(attribute, public_send(attribute))] } ) end |
#to_h ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/igniter/extensions/contracts/mcp/creator_session.rb', line 86 def to_h wizard.to_h.merge( session: { name: name, kind: kind, namespace: namespace, profile: profile, capabilities: Array(capabilities).map(&:to_sym), scope: scope, root: root, mode: mode, target_profile_fingerprint: target_profile&.fingerprint } ) end |
#wizard ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/igniter/extensions/contracts/mcp/creator_session.rb', line 59 def wizard CreatorPack.wizard( name: name, kind: kind, namespace: namespace, profile: profile, capabilities: capabilities, scope: scope, root: root, mode: mode, pack: pack, target_profile: target_profile ) end |
#workflow_payload ⇒ Object
74 75 76 |
# File 'lib/igniter/extensions/contracts/mcp/creator_session.rb', line 74 def workflow_payload wizard.workflow.to_h end |
#write_payload ⇒ Object
82 83 84 |
# File 'lib/igniter/extensions/contracts/mcp/creator_session.rb', line 82 def write_payload wizard.writer.write.to_h end |
#write_plan_payload ⇒ Object
78 79 80 |
# File 'lib/igniter/extensions/contracts/mcp/creator_session.rb', line 78 def write_plan_payload wizard.writer.plan.to_h end |