Exception: Contracts::Violation
- Defined in:
- lib/contracts.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#actual ⇒ Object
readonly
Returns the value of attribute actual.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#contract_type ⇒ Object
readonly
Returns the value of attribute contract_type.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#expected ⇒ Object
readonly
Returns the value of attribute expected.
-
#method_name ⇒ Object
readonly
Returns the value of attribute method_name.
-
#original_exception ⇒ Object
readonly
Returns the value of attribute original_exception.
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
-
#parameter ⇒ Object
readonly
Returns the value of attribute parameter.
-
#source_location ⇒ Object
readonly
Returns the value of attribute source_location.
Instance Method Summary collapse
-
#initialize(message = nil, owner: nil, method_name: nil, contract_type: nil, description: nil, expected: nil, actual: nil, parameter: nil, context: nil, source_location: nil, original_exception: nil) ⇒ Violation
constructor
A new instance of Violation.
Methods inherited from Error
Constructor Details
#initialize(message = nil, owner: nil, method_name: nil, contract_type: nil, description: nil, expected: nil, actual: nil, parameter: nil, context: nil, source_location: nil, original_exception: nil) ⇒ Violation
Returns a new instance of Violation.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/contracts.rb', line 23 def initialize( = nil, owner: nil, method_name: nil, contract_type: nil, description: nil, expected: nil, actual: nil, parameter: nil, context: nil, source_location: nil, original_exception: nil) @owner = owner @method_name = method_name @contract_type = contract_type @description = description @expected = expected @actual = actual @parameter = parameter @context = context @source_location = source_location @original_exception = original_exception super( || "#{owner}##{method_name} violated #{contract_type}: #{description || expected}") end |
Instance Attribute Details
#actual ⇒ Object (readonly)
Returns the value of attribute actual.
20 21 22 |
# File 'lib/contracts.rb', line 20 def actual @actual end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
20 21 22 |
# File 'lib/contracts.rb', line 20 def context @context end |
#contract_type ⇒ Object (readonly)
Returns the value of attribute contract_type.
20 21 22 |
# File 'lib/contracts.rb', line 20 def contract_type @contract_type end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
20 21 22 |
# File 'lib/contracts.rb', line 20 def description @description end |
#expected ⇒ Object (readonly)
Returns the value of attribute expected.
20 21 22 |
# File 'lib/contracts.rb', line 20 def expected @expected end |
#method_name ⇒ Object (readonly)
Returns the value of attribute method_name.
20 21 22 |
# File 'lib/contracts.rb', line 20 def method_name @method_name end |
#original_exception ⇒ Object (readonly)
Returns the value of attribute original_exception.
20 21 22 |
# File 'lib/contracts.rb', line 20 def original_exception @original_exception end |
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
20 21 22 |
# File 'lib/contracts.rb', line 20 def owner @owner end |
#parameter ⇒ Object (readonly)
Returns the value of attribute parameter.
20 21 22 |
# File 'lib/contracts.rb', line 20 def parameter @parameter end |
#source_location ⇒ Object (readonly)
Returns the value of attribute source_location.
20 21 22 |
# File 'lib/contracts.rb', line 20 def source_location @source_location end |