Class: Ibex::Configuration::Evidence
- Inherits:
-
Object
- Object
- Ibex::Configuration::Evidence
- Defined in:
- lib/ibex/configuration/explanation.rb
Overview
One observed configuration source and how it participated in selection.
Constant Summary collapse
- STATUSES =
: Array
%i[accepted ignored duplicate conflicting].freeze
- SOURCES =
: Array
%i[grammar project cli].freeze
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
: Key.
-
#location ⇒ Object
readonly
: Location?.
-
#reason ⇒ Object
readonly
: String.
-
#source ⇒ Object
readonly
: Symbol.
-
#status ⇒ Object
readonly
: Symbol.
-
#value ⇒ Object
readonly
: config_value.
Instance Method Summary collapse
-
#initialize(key, source:, value:, status:, reason:, location: nil) ⇒ Evidence
constructor
A new instance of Evidence.
- #to_h ⇒ Object
Constructor Details
#initialize(key, source:, value:, status:, reason:, location: nil) ⇒ Evidence
Returns a new instance of Evidence.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ibex/configuration/explanation.rb', line 20 def initialize(key, source:, value:, status:, reason:, location: nil) raise ArgumentError, "configuration evidence key must be a Configuration::Key" unless key.is_a?(Key) raise ArgumentError, "unknown configuration evidence source: #{source.inspect}" unless SOURCES.include?(source) raise ArgumentError, "unknown configuration evidence status: #{status.inspect}" unless STATUSES.include?(status) unless location.nil? || location.is_a?(Location) raise ArgumentError, "configuration evidence location must be an Ibex::Location" end raise ArgumentError, "configuration evidence reason must not be empty" if reason.empty? @key = key @source = source @value = key.validate(value) @status = status @location = location @reason = reason.dup.freeze freeze end |
Instance Attribute Details
#key ⇒ Object (readonly)
: Key
11 12 13 |
# File 'lib/ibex/configuration/explanation.rb', line 11 def key @key end |
#location ⇒ Object (readonly)
: Location?
15 16 17 |
# File 'lib/ibex/configuration/explanation.rb', line 15 def location @location end |
#reason ⇒ Object (readonly)
: String
16 17 18 |
# File 'lib/ibex/configuration/explanation.rb', line 16 def reason @reason end |
#source ⇒ Object (readonly)
: Symbol
12 13 14 |
# File 'lib/ibex/configuration/explanation.rb', line 12 def source @source end |
#status ⇒ Object (readonly)
: Symbol
14 15 16 |
# File 'lib/ibex/configuration/explanation.rb', line 14 def status @status end |
#value ⇒ Object (readonly)
: config_value
13 14 15 |
# File 'lib/ibex/configuration/explanation.rb', line 13 def value @value end |
Instance Method Details
#to_h ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/ibex/configuration/explanation.rb', line 39 def to_h result = { "source" => @source.to_s, "value" => json_value(@value), "status" => @status.to_s, "reason" => @reason } #: Hash[String, json_value] location = @location result["location"] = location.to_h.transform_keys(&:to_s) if location result end |