Class: Ibex::Configuration::ConflictRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/ibex/configuration/explanation.rb,
sig/ibex/configuration/explanation.rbs

Overview

A fixed-contract mismatch retained as structured report data.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(conflict) ⇒ ConflictRecord

Returns a new instance of ConflictRecord.

RBS:

  • (Conflict conflict) -> void

Parameters:



223
224
225
226
227
228
229
230
# File 'lib/ibex/configuration/explanation.rb', line 223

def initialize(conflict)
  raise ArgumentError, "conflict record requires a Configuration::Conflict" unless conflict.is_a?(Conflict)

  @key = conflict.key
  @declared = conflict.declared
  @requested = conflict.requested
  freeze
end

Instance Attribute Details

#declaredValue (readonly)

Signature:

  • Value

Returns:



219
220
221
# File 'lib/ibex/configuration/explanation.rb', line 219

def declared
  @declared
end

#keyKey (readonly)

Signature:

  • Key

Returns:



218
219
220
# File 'lib/ibex/configuration/explanation.rb', line 218

def key
  @key
end

#requestedValue (readonly)

Signature:

  • Value

Returns:



220
221
222
# File 'lib/ibex/configuration/explanation.rb', line 220

def requested
  @requested
end

Instance Method Details

#messageString

RBS:

  • () -> String

Returns:

  • (String)


243
244
245
246
247
248
249
# File 'lib/ibex/configuration/explanation.rb', line 243

def message
  location = @declared.origin.location
  prefix = location ? "#{location.file || '(source)'}:#{location.line}:#{location.column}: " : "(config):1:1: "
  "#{prefix}configuration conflict for #{@key.name}: " \
    "#{@declared.origin.label} selected #{@declared.value.inspect}, " \
    "#{@requested.origin.label} requested #{@requested.value.inspect}"
end

#selection(value) ⇒ Hash[String, json_value]

RBS:

  • (Value value) -> Hash[String, json_value]

Parameters:

Returns:

  • (Hash[String, json_value])


254
255
256
257
# File 'lib/ibex/configuration/explanation.rb', line 254

def selection(value)
  serialized = value.to_h
  { "value" => serialized.fetch("value"), "origin" => serialized.fetch("origin") }
end

#to_hHash[String, json_value]

RBS:

  • () -> Hash[String, json_value]

Returns:

  • (Hash[String, json_value])


233
234
235
236
237
238
239
240
# File 'lib/ibex/configuration/explanation.rb', line 233

def to_h
  {
    "key" => @key.name,
    "policy" => @key.policy.to_s,
    "declared" => selection(@declared),
    "requested" => selection(@requested)
  }
end