Class: Mammoth::Commands::BootstrapCommand
- Inherits:
-
Object
- Object
- Mammoth::Commands::BootstrapCommand
- Defined in:
- lib/mammoth/commands/bootstrap_command.rb
Overview
Initializes the configured operational-state backend.
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#state_adapter ⇒ Object
readonly
Returns the value of attribute state_adapter.
Instance Method Summary collapse
-
#call ⇒ Integer
Process-style status code.
-
#initialize(config, state_adapter: nil, output: $stdout) ⇒ BootstrapCommand
constructor
A new instance of BootstrapCommand.
Constructor Details
#initialize(config, state_adapter: nil, output: $stdout) ⇒ BootstrapCommand
Returns a new instance of BootstrapCommand.
12 13 14 15 16 |
# File 'lib/mammoth/commands/bootstrap_command.rb', line 12 def initialize(config, state_adapter: nil, output: $stdout) @config = config @state_adapter = state_adapter || OperationalState::Registry.build_configured(config) @output = output end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
7 8 9 |
# File 'lib/mammoth/commands/bootstrap_command.rb', line 7 def config @config end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
7 8 9 |
# File 'lib/mammoth/commands/bootstrap_command.rb', line 7 def output @output end |
#state_adapter ⇒ Object (readonly)
Returns the value of attribute state_adapter.
7 8 9 |
# File 'lib/mammoth/commands/bootstrap_command.rb', line 7 def state_adapter @state_adapter end |
Instance Method Details
#call ⇒ Integer
Returns process-style status code.
19 20 21 22 23 24 25 26 27 |
# File 'lib/mammoth/commands/bootstrap_command.rb', line 19 def call state_adapter.bootstrap! summary = state_adapter.summary output.puts "Operational state initialized" output.puts "Adapter: #{summary.fetch(:adapter)}" output.puts "Path: #{summary.fetch(:path)}" if summary.key?(:path) output.puts "Tables: #{Array(summary.fetch(:tables)).join(", ")}" if summary.key?(:tables) 0 end |