Module: Voom::Commands::Namespace
Instance Method Summary collapse
-
#namespace_errors(lambda, namespace) ⇒ Object
Will put the commands errors into a nested namespace in the error hash This allows you to use a top-level command and then nest its errors into another model This example the cart has shipping and billing addresses, so it does not make sense to bubble the address fields and errors up to the top level.
- #namespace_errors!(lambda, namespace) ⇒ Object
Methods included from ExtractErrors
#extract_errors, #extract_fk_errors
Instance Method Details
#namespace_errors(lambda, namespace) ⇒ Object
Will put the commands errors into a nested namespace in the error hash This allows you to use a top-level command and then nest its errors into another model This example the cart has shipping and billing addresses, so it does not make sense to bubble the address fields and errors up to the top level.
8 9 10 11 12 13 14 |
# File 'lib/voom/commands/namespace.rb', line 8 def namespace_errors(lambda, namespace) begin lambda.call rescue Errors::ParameterValidation => e {namespace => extract_errors(e)} end end |
#namespace_errors!(lambda, namespace) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/voom/commands/namespace.rb', line 16 def namespace_errors!(lambda, namespace) response = namespace_errors(lambda, namespace) raise Errors::ParameterValidation.new('Form validation failed.', response) if response.respond_to?(:include?) && response.include?(namespace) response end |