Class: ParametersSchema::Schema
- Defined in:
- lib/parameters_schema/schema.rb
Instance Method Summary collapse
-
#initialize(&schema) ⇒ Schema
constructor
A new instance of Schema.
- #validate!(params) ⇒ Object
Constructor Details
#initialize(&schema) ⇒ Schema
Returns a new instance of Schema.
3 4 5 |
# File 'lib/parameters_schema/schema.rb', line 3 def initialize(&schema) @schema = schema end |
Instance Method Details
#validate!(params) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/parameters_schema/schema.rb', line 7 def validate!(params) # Make sure we have params we can work with. @params = __prepare_params(params) # Parse and validate each param. @sanitized_params = [] instance_eval(&@schema) # Serve the params if valid, otherwise throw exception. __handle_errors __serve end |