Exception: Otoroshi::NotAcceptedError
- Defined in:
- lib/otoroshi/exceptions.rb
Overview
Manages errors raised when value is not accepted (not included in the “one_of”)
Instance Method Summary collapse
-
#initialize(property, accepted_values, array: false) ⇒ NotAcceptedError
constructor
Initialize an error.
Constructor Details
#initialize(property, accepted_values, array: false) ⇒ NotAcceptedError
Initialize an error
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/otoroshi/exceptions.rb', line 43 def initialize(property, accepted_values, array: false) # reintegrate the colon for symbols which is lost during interpolation to_s = ->(v) { v.is_a?(Symbol) ? ":#{v}" : v } accepted_values_list = accepted_values.map { |v| to_s.call(v) }.join(', ') msg = if array ":#{property} contains elements that are not included in [#{accepted_values_list}]" else ":#{property} is not included in [#{accepted_values_list}]" end super(msg) end |