Module: Cuprum::ParameterValidation

Extended by:
SleepingKingStudios::Tools::Toolbox::Mixin
Defined in:
lib/cuprum/parameter_validation.rb,
lib/cuprum/parameter_validation/validator.rb,
lib/cuprum/parameter_validation/validation_rule.rb

Overview

Mixin for declaring validations for command parameters.

Defined Under Namespace

Modules: ClassMethods Classes: ValidationRule, Validator

Instance Method Summary collapse

Instance Method Details

#call(*arguments, **keywords, &block) ⇒ Cuprum::Result

Validates the parameters and passes them to super.

Parameters:

  • arguments (Array)

    the arguments to validate.

  • keywords (Hash)

    the keywords to validate.

  • block (Proc)

    the block to validate, if any,

Returns:

  • (Cuprum::Result)

    a failing result with a Cuprum::Errors::InvalidParameters error if the validation fails; otherwise the normal result of calling the command.

See Also:

  • Cuprum::Processing#call.


212
213
214
215
216
217
218
# File 'lib/cuprum/parameter_validation.rb', line 212

def call(...)
  result = self.class.validate_parameters(self, ...)

  return result if result.failure?

  super
end