Module: Cuprum::Rails::Actions::ParameterValidation::ClassMethods

Defined in:
lib/cuprum/rails/actions/parameter_validation.rb

Overview

Class methods to extend when including the mixin.

Instance Method Summary collapse

Instance Method Details

#validate_parameters(contract) ⇒ Object #validate_parameters { ... } ⇒ Object

Overloads:

  • #validate_parameters(contract) ⇒ Object

    Sets the contract to automatically validate the request parameters.

    Parameters:

    • contract (Stannum::Contract)

      the contract used to validate the request parameters.

  • #validate_parameters { ... } ⇒ Object

    Defines a contract to automatically validate the request parameters.

    Yields:

    • Used to create an indifferent hash contract to validate the request parameters.



26
27
28
29
30
# File 'lib/cuprum/rails/actions/parameter_validation.rb', line 26

def validate_parameters(contract = nil, &block)
  contract ||= Cuprum::Rails::Constraints::ParametersContract.new(&block)

  define_method(:parameters_contract) { contract }
end