Class: SmartCore::Validator::Commands::AddNestedValidations Private

Inherits:
Base
  • Object
show all
Includes:
WorkWithNestedsMixin
Defined in:
lib/smart_core/validator/commands/add_nested_validations.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.

Since:

  • 0.1.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from WorkWithNestedsMixin

#build_nested_validator, #build_sub_validator, #check_nested_validations

Constructor Details

#initialize(validating_method, nested_validations) ⇒ void

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.

Parameters:

  • validating_method (Symbol, String)
  • nested_validations (Proc)

Since:

  • 0.1.0



28
29
30
31
# File 'lib/smart_core/validator/commands/add_nested_validations.rb', line 28

def initialize(validating_method, nested_validations)
  @validating_method = validating_method
  @nested_validations = nested_validations
end

Instance Attribute Details

#nested_validationsProc (readonly)

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:

  • (Proc)

Since:

  • 0.1.0



20
21
22
# File 'lib/smart_core/validator/commands/add_nested_validations.rb', line 20

def nested_validations
  @nested_validations
end

#validating_methodSymbol, String (readonly)

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:

  • (Symbol, String)

Since:

  • 0.1.0



14
15
16
# File 'lib/smart_core/validator/commands/add_nested_validations.rb', line 14

def validating_method
  @validating_method
end

Instance Method Details

#call(validator) ⇒ void

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.

This method returns an undefined value.

Parameters:

Since:

  • 0.1.0



38
39
40
41
42
43
44
45
46
# File 'lib/smart_core/validator/commands/add_nested_validations.rb', line 38

def call(validator)
  errors = SmartCore::Validator::Invoker.call(validator, validating_method)

  if errors.empty?
    check_nested_validations(validator, nested_validations)
  else
    validator.__append_errors__(errors)
  end
end