class Otoroshi::OneOfError

Manages errors raised when value is not accepted (not in the “one_of”)

Public Class Methods

new(property, values) click to toggle source

@param property [Symbol] name of the property @param values [Array] accepted values @example

":fruit is not in [:apple, :pear]"
Calls superclass method
# File lib/otoroshi/exceptions.rb, line 25
def initialize(property, values)
  # reintegrate the colon for symbols which is lost during interpolation
  to_s = ->(v) { v.is_a?(Symbol) ? ":#{v}" : v }
  list = values.map { |v| to_s.call(v) }.join(', ')
  super ":#{property} is not in [#{list}]"
end