Class: Qonfig::Validator::MethodBased Private

Inherits:
Basic
  • Object
show all
Defined in:
lib/qonfig/validator/method_based.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.13.0

Instance Attribute Summary collapse

Attributes inherited from Basic

#setting_key_matcher

Instance Method Summary collapse

Methods inherited from Basic

#validate

Constructor Details

#initialize(setting_key_matcher, runtime_validation_method) ⇒ 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:

Since:

  • 0.13.0



18
19
20
21
# File 'lib/qonfig/validator/method_based.rb', line 18

def initialize(setting_key_matcher, runtime_validation_method)
  super(setting_key_matcher)
  @runtime_validation_method = runtime_validation_method
end

Instance Attribute Details

#runtime_validation_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.13.0



10
11
12
# File 'lib/qonfig/validator/method_based.rb', line 10

def runtime_validation_method
  @runtime_validation_method
end

Instance Method Details

#validate_concrete(data_set) ⇒ Boolean

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:

Returns:

  • (Boolean)

Since:

  • 0.13.0



28
29
30
31
32
33
34
35
36
37
# File 'lib/qonfig/validator/method_based.rb', line 28

def validate_concrete(data_set)
  data_set.settings.__deep_each_setting__ do |setting_key, setting_value|
    next unless setting_key_matcher.match?(setting_key)

    raise(
      Qonfig::ValidationError,
      "Invalid value of setting <#{setting_key}> (#{setting_value})"
    ) unless data_set.__send__(runtime_validation_method, setting_value)
  end
end

#validate_full(data_set) ⇒ Boolean

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:

Returns:

  • (Boolean)

Since:

  • 0.13.0



44
45
46
47
48
# File 'lib/qonfig/validator/method_based.rb', line 44

def validate_full(data_set)
  unless data_set.__send__(runtime_validation_method)
    raise(Qonfig::ValidationError, 'Invalid config object')
  end
end