class ContractValueObject::ErrorFormatter

Public Instance Methods

contract_failure(attribute, value, contract) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# File lib/contract_value_object/error_formatter.rb, line 23
def unexpected(attribute)
  "Unexpected attribute `#{attribute}`."
end