Class: Qonfig::Validator::Predefined::Registry Private
- Inherits:
-
Object
- Object
- Qonfig::Validator::Predefined::Registry
- Defined in:
- lib/qonfig/validator/predefined/registry.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.
Instance Method Summary collapse
- #initialize ⇒ void constructor private
- #register(name, &validation) ⇒ void private
- #resolve(name) ⇒ Qonfig::Validator::ProcBased, Qonfig::Validator::MethodBased private
Constructor Details
#initialize ⇒ 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.
10 11 12 13 |
# File 'lib/qonfig/validator/predefined/registry.rb', line 10 def initialize @validators = {} @lock = Mutex.new end |
Instance Method Details
#register(name, &validation) ⇒ 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.
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/qonfig/validator/predefined/registry.rb', line 23 def register(name, &validation) thread_safe do name = indifferently_accessable_name(name) raise( Qonfig::ValidatorArgumentError, "Predefined validator with name '#{name}' already exists." ) if validators.key?(name) validators[name] = validation end end |
#resolve(name) ⇒ Qonfig::Validator::ProcBased, Qonfig::Validator::MethodBased
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.
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/qonfig/validator/predefined/registry.rb', line 43 def resolve(name) thread_safe do begin validators.fetch(indifferently_accessable_name(name)) rescue KeyError raise( Qonfig::ValidatorArgumentError, "Predefined validator with name '#{name}' does not exist." ) end end end |