Class: ContractValueObject::ErrorFormatter
- Inherits:
-
Object
- Object
- ContractValueObject::ErrorFormatter
- Includes:
- Contracts
- Defined in:
- lib/contract_value_object/error_formatter.rb
Instance Method Summary collapse
- #contract_failure(attribute, value, contract) ⇒ Object
- #missing(attribute, contract) ⇒ Object
- #unexpected(attribute) ⇒ Object
Instance Method Details
#contract_failure(attribute, value, contract) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/contract_value_object/error_formatter.rb', line 6 def contract_failure(attribute, value, contract) [ "Attribute `#{attribute}` does not conform to its contract.", "\tExpected: #{Contracts::Formatters::Expected.new(contract).contract}", "\tActual: #{value.class.name} (#{value.inspect})", ].join("\n") end |
#missing(attribute, contract) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/contract_value_object/error_formatter.rb', line 15 def missing(attribute, contract) [ "Missing attribute `#{attribute}`.", "\tExpected: #{Contracts::Formatters::Expected.new(contract).contract}", ].join("\n") end |
#unexpected(attribute) ⇒ Object
23 24 25 |
# File 'lib/contract_value_object/error_formatter.rb', line 23 def unexpected(attribute) "Unexpected attribute `#{attribute}`." end |