Class: Etcher::Resolver

Inherits:
Object
  • Object
show all
Defined in:
lib/etcher/resolver.rb

Overview

Builds and fully resolves a configuration.

Instance Method Summary collapse

Constructor Details

#initialize(registry = Registry.new, kernel: Kernel, logger: LOGGER) ⇒ Resolver

Returns a new instance of Resolver.



13
14
15
16
17
# File 'lib/etcher/resolver.rb', line 13

def initialize registry = Registry.new, kernel: Kernel, logger: LOGGER
  @builder = Builder.new registry
  @kernel = kernel
  @logger = logger
end

Instance Method Details

#call(**overrides) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/etcher/resolver.rb', line 19

def call(**overrides)
  case builder.call(**overrides)
    in Success(attributes) then attributes
    in Failure(step:, payload: String => payload)
      logger.fatal { "Build failure: #{step.inspect}. #{payload}" }
      kernel.abort
    in Failure(step:, payload: Hash => payload) then log_and_abort payload
    else fail StandardError, "Unable to parse configuration."
  end
end