class ParamsReady::Parameter::ArrayParameterDefinition
Public Class Methods
new(*args, prototype: nil, **options)
click to toggle source
Calls superclass method
# File lib/params_ready/parameter/array_parameter.rb, line 155 def initialize(*args, prototype: nil, **options) raise ParamsReadyError, "Not a definition: #{prototype.class.name}" unless (prototype.is_a?(Definition) || prototype.nil?) @prototype = prototype super *args, **options end
Public Instance Methods
ensure_canonical(array)
click to toggle source
# File lib/params_ready/parameter/array_parameter.rb, line 173 def ensure_canonical(array) raise "Not a canonical value, array expected, got: '#{array.class.name}'" unless array.is_a? Array context = Format.instance(:backend) value, _validator = try_canonicalize(array, context, nil, freeze: true) value end
finish()
click to toggle source
Calls superclass method
# File lib/params_ready/parameter/array_parameter.rb, line 189 def finish if compact? && (prototype&.default_defined?) raise ParamsReadyError, 'Prototype must not be optional nor have default in compact array parameter' end super end
set_default(args)
click to toggle source
Calls superclass method
# File lib/params_ready/parameter/array_parameter.rb, line 161 def set_default(args) raise ParamsReadyError, "Can't set default before prototype has been defined" if @prototype.nil? super end
try_canonicalize(value, context, validator = nil, freeze: false)
click to toggle source
Calls superclass method
# File lib/params_ready/parameter/array_parameter.rb, line 180 def try_canonicalize(value, context, validator = nil, freeze: false) if freeze marshaller = marshallers.instance(Array) marshaller.canonicalize self, value, context, validator, freeze: freeze else super value, context, validator end end