Class: Stoplight::Domain::CompatibilityResult
- Inherits:
-
Object
- Object
- Stoplight::Domain::CompatibilityResult
- Defined in:
- lib/stoplight/domain/compatibility_result.rb
Overview
The CompatibilityResult class represents the result of a compatibility check for a strategy. It provides methods to determine if the strategy is compatible and to retrieve error messages when it is not.
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Retrieves the list of error messages.
Class Method Summary collapse
-
.compatible ⇒ Object
Creates a new
CompatibilityResultinstance representing a compatible strategy. -
.incompatible(*errors) ⇒ Object
Creates a new
CompatibilityResultinstance representing an incompatible strategy.
Instance Method Summary collapse
-
#compatible? ⇒ Boolean
Checks if the strategy is compatible.
-
#error_messages ⇒ Object
Retrieves a concatenated error message string.
- #incompatible? ⇒ Boolean
-
#initialize(errors: []) ⇒ CompatibilityResult
constructor
Initializes a new
CompatibilityResultinstance.
Constructor Details
#initialize(errors: []) ⇒ CompatibilityResult
Initializes a new CompatibilityResult instance.
28 29 30 |
# File 'lib/stoplight/domain/compatibility_result.rb', line 28 def initialize(errors: []) @errors = errors.freeze end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Retrieves the list of error messages.
43 44 45 |
# File 'lib/stoplight/domain/compatibility_result.rb', line 43 def errors @errors end |
Class Method Details
.compatible ⇒ Object
Creates a new CompatibilityResult instance representing a compatible strategy.
13 14 15 |
# File 'lib/stoplight/domain/compatibility_result.rb', line 13 def compatible new(errors: []) end |
.incompatible(*errors) ⇒ Object
Creates a new CompatibilityResult instance representing an incompatible strategy.
21 22 23 |
# File 'lib/stoplight/domain/compatibility_result.rb', line 21 def incompatible(*errors) new(errors:) end |
Instance Method Details
#compatible? ⇒ Boolean
Checks if the strategy is compatible.
34 35 36 |
# File 'lib/stoplight/domain/compatibility_result.rb', line 34 def compatible? @errors.empty? end |
#error_messages ⇒ Object
Retrieves a concatenated error message string.
48 49 50 51 52 |
# File 'lib/stoplight/domain/compatibility_result.rb', line 48 def unless compatible? @errors.join("; ") end end |
#incompatible? ⇒ Boolean
38 |
# File 'lib/stoplight/domain/compatibility_result.rb', line 38 def incompatible? = !compatible? |