lib/grape/validations/validators/base.rb in grape-1.5.1 vs lib/grape/validations/validators/base.rb in grape-1.5.2
- old
+ new
@@ -10,17 +10,18 @@
# parameter definition.
# @param attrs [Array] names of attributes to which the Validator applies
# @param options [Object] implementation-dependent Validator options
# @param required [Boolean] attribute(s) are required or optional
# @param scope [ParamsScope] parent scope for this Validator
- # @param opts [Hash] additional validation options
- def initialize(attrs, options, required, scope, **opts)
+ # @param opts [Array] additional validation options
+ def initialize(attrs, options, required, scope, *opts)
@attrs = Array(attrs)
@option = options
@required = required
@scope = scope
- @fail_fast = opts[:fail_fast] || false
- @allow_blank = opts[:allow_blank] || false
+ opts = opts.any? ? opts.shift : {}
+ @fail_fast = opts.fetch(:fail_fast, false)
+ @allow_blank = opts.fetch(:allow_blank, false)
end
# Validates a given request.
# @note Override #validate! unless you need to access the entire request.
# @param request [Grape::Request] the request currently being handled