Exception: Constrain::MatchError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/constrain.rb

Overview

Raised if types doesn’t match a class expression

Instance Method Summary collapse

Constructor Details

#initialize(value, exprs, message: nil, unwind: 0, not_argument: false, not_value: nil) ⇒ MatchError

Returns a new instance of MatchError.



6
7
8
9
10
11
12
# File 'lib/constrain.rb', line 6

def initialize(value, exprs, message: nil, unwind: 0, not_argument: false, not_value: nil)
  if not_argument
    super message || "Expected #{value.inspect} to not equal #{not_value.inspect}"
  else
    super message || "Expected #{value.inspect} to match #{Constrain.fmt_exprs(exprs)}"
  end
end