Module: CMDx::Validators::Validate
Overview
Invokes an inline ‘:validate` handler. Used by #validate for each handler passed under the `:validate` option.
Instance Method Summary collapse
-
#call(task, value, handler) ⇒ Validators::Failure, ...
Handler’s return value.
Instance Method Details
#call(task, value, handler) ⇒ Validators::Failure, ...
Returns handler’s return value.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/cmdx/validators/validate.rb', line 16 def call(task, value, handler) case handler when Symbol task.send(handler, value) when Proc task.instance_exec(value, &handler) else return handler.call(value, task) if handler.respond_to?(:call) raise ArgumentError, "validate handler must be a Symbol, Proc, or respond to #call" end end |