Exception: Contracts::CompositeViolation
- Defined in:
- lib/contracts.rb
Instance Attribute Summary collapse
-
#violations ⇒ Object
readonly
Returns the value of attribute violations.
Attributes inherited from Violation
#actual, #context, #contract_type, #description, #expected, #method_name, #original_exception, #owner, #parameter, #source_location
Instance Method Summary collapse
-
#initialize(violations:, original_exception: nil) ⇒ CompositeViolation
constructor
A new instance of CompositeViolation.
- #primary_violation ⇒ Object
Methods inherited from Error
Constructor Details
#initialize(violations:, original_exception: nil) ⇒ CompositeViolation
Returns a new instance of CompositeViolation.
58 59 60 61 |
# File 'lib/contracts.rb', line 58 def initialize(violations:, original_exception: nil) @violations = violations.freeze super("multiple contract violations: #{violations.map(&:message).join('; ')}", original_exception: original_exception) end |
Instance Attribute Details
#violations ⇒ Object (readonly)
Returns the value of attribute violations.
56 57 58 |
# File 'lib/contracts.rb', line 56 def violations @violations end |
Instance Method Details
#primary_violation ⇒ Object
63 |
# File 'lib/contracts.rb', line 63 def primary_violation = violations.first |