Class: Committee::SchemaValidator::HyperSchema::StringParamsCoercer
- Inherits:
-
Object
- Object
- Committee::SchemaValidator::HyperSchema::StringParamsCoercer
- Defined in:
- lib/committee/schema_validator/hyper_schema/string_params_coercer.rb
Overview
StringParamsCoercer takes parameters that are specified over a medium that can only accept strings (for example in a URL path or in query parameters) and attempts to coerce them into known types based of a link’s schema definition.
Currently supported types: null, integer, number and boolean.
call
returns a hash of all params which could be coerced - coercion errors are simply ignored and expected to be handled later by schema validation.
Instance Method Summary collapse
- #call! ⇒ Object
-
#initialize(query_hash, schema, options = {}) ⇒ StringParamsCoercer
constructor
A new instance of StringParamsCoercer.
Constructor Details
#initialize(query_hash, schema, options = {}) ⇒ StringParamsCoercer
Returns a new instance of StringParamsCoercer.
17 18 19 20 21 22 |
# File 'lib/committee/schema_validator/hyper_schema/string_params_coercer.rb', line 17 def initialize(query_hash, schema, = {}) @query_hash = query_hash @schema = schema @coerce_recursive = .fetch(:coerce_recursive, false) end |
Instance Method Details
#call! ⇒ Object
24 25 26 |
# File 'lib/committee/schema_validator/hyper_schema/string_params_coercer.rb', line 24 def call! coerce_object!(@query_hash, @schema) end |