Class: StandardCircuit::Config::CircuitSpec

Inherits:
Struct
  • Object
show all
Defined in:
lib/standard_circuit/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#cool_off_timeObject

Returns the value of attribute cool_off_time

Returns:

  • (Object)

    the current value of cool_off_time



9
10
11
# File 'lib/standard_circuit/config.rb', line 9

def cool_off_time
  @cool_off_time
end

#criticalityObject

Returns the value of attribute criticality

Returns:

  • (Object)

    the current value of criticality



9
10
11
# File 'lib/standard_circuit/config.rb', line 9

def criticality
  @criticality
end

#skipped_errorsObject

Returns the value of attribute skipped_errors

Returns:

  • (Object)

    the current value of skipped_errors



9
10
11
# File 'lib/standard_circuit/config.rb', line 9

def skipped_errors
  @skipped_errors
end

#thresholdObject

Returns the value of attribute threshold

Returns:

  • (Object)

    the current value of threshold



9
10
11
# File 'lib/standard_circuit/config.rb', line 9

def threshold
  @threshold
end

#tracked_errorsObject

Returns the value of attribute tracked_errors

Returns:

  • (Object)

    the current value of tracked_errors



9
10
11
# File 'lib/standard_circuit/config.rb', line 9

def tracked_errors
  @tracked_errors
end

#window_sizeObject

Returns the value of attribute window_size

Returns:

  • (Object)

    the current value of window_size



9
10
11
# File 'lib/standard_circuit/config.rb', line 9

def window_size
  @window_size
end

Class Method Details

.build(**opts) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/standard_circuit/config.rb', line 18

def self.build(**opts)
  criticality = opts.fetch(:criticality, DEFAULT_CRITICALITY)
  unless CRITICALITIES.include?(criticality)
    raise ArgumentError,
      "invalid criticality #{criticality.inspect}; must be one of #{CRITICALITIES.inspect}"
  end

  new(
    threshold: opts.fetch(:threshold, DEFAULT_THRESHOLD),
    cool_off_time: opts.fetch(:cool_off_time, DEFAULT_COOL_OFF),
    window_size: opts.fetch(:window_size, DEFAULT_WINDOW),
    tracked_errors: opts.fetch(:tracked_errors, NetworkErrors.defaults),
    skipped_errors: opts.fetch(:skipped_errors, []),
    criticality: criticality
  )
end