Class: Cuprum::ParameterValidation::ValidationRule Private

Inherits:
Struct
  • Object
show all
Defined in:
lib/cuprum/parameter_validation/validation_rule.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Value class representing a single validation for a parameter.

Constant Summary collapse

BLOCK_VALIDATION_TYPE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Custom validation type for a block validation.

:_block_validation
NAMED_VALIDATION_TYPE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Custom validation type for a named method validation.

:_named_method_validation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, type:, method_name: nil, **options, &block) ⇒ ValidationRule

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ValidationRule.

Parameters:

  • name (Symbol)

    the name of the parameter to validate.

  • type (Symbol)

    the type of validation to perform.

  • method_name (Symbol) (defaults to: nil)

    the name for the validation method.

  • options (Hash)

    additional options to pass to the validator.

  • block (Proc)

    a block to pass to the validator, if any.



28
29
30
31
32
33
34
35
36
# File 'lib/cuprum/parameter_validation/validation_rule.rb', line 28

def initialize(name:, type:, method_name: nil, **options, &block)
  super(
    block:,
    method_name: method_name&.to_sym || method_name_for(name:, type:),
    name:        name.to_sym,
    options:,
    type:        type.to_sym
  )
end

Instance Attribute Details

#blockObject

Returns the value of attribute block

Returns:

  • (Object)

    the current value of block



9
10
11
# File 'lib/cuprum/parameter_validation/validation_rule.rb', line 9

def block
  @block
end

#method_nameObject

Returns the value of attribute method_name

Returns:

  • (Object)

    the current value of method_name



9
10
11
# File 'lib/cuprum/parameter_validation/validation_rule.rb', line 9

def method_name
  @method_name
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



9
10
11
# File 'lib/cuprum/parameter_validation/validation_rule.rb', line 9

def name
  @name
end

#optionsObject

Returns the value of attribute options

Returns:

  • (Object)

    the current value of options



9
10
11
# File 'lib/cuprum/parameter_validation/validation_rule.rb', line 9

def options
  @options
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



9
10
11
# File 'lib/cuprum/parameter_validation/validation_rule.rb', line 9

def type
  @type
end