Sha256: 4bdde919ee758cd2378f2ed0ff247c597a5474d88dc8ef01c5c9991fa9635643

Contents?: true

Size: 1.08 KB

Versions: 5

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

# @api private
# @since 0.13.0
module Qonfig::Validator::Predefined::RegistryControlMixin
  class << self
    # @param basic_klass [Class, Module]
    # @return [void]
    #
    # @api private
    # @since 0.13.0
    def extended(basic_klass)
      basic_klass.instance_variable_set(:@registry, Qonfig::Validator::Predefined::Registry.new)
    end
  end

  # @return [Qonfig::Validator::Predefined::Registry]
  #
  # @api private
  # @since 0.13.0
  attr_reader :registry

  # @param name [String, Symbol]
  # @param validation [Proc]
  # @return [void]
  #
  # @api private
  # @since 0.13.0
  def predefine(name, &validation)
    registry.register(name, &validation)
  end

  # @param name [String, Symbol]
  # @param setting_key_matcher [Qonfig::Setting::KeyMatcher]
  # @param strict [Boolean]
  # @return [Qonfig::Validator::Predefined::Common]
  #
  # @api private
  # @since 0.13.0
  def build(name, setting_key_matcher, strict)
    validation = registry.resolve(name)
    Qonfig::Validator::Predefined::Common.new(setting_key_matcher, strict, validation)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
qonfig-0.19.1 lib/qonfig/validator/predefined/registry_control_mixin.rb
qonfig-0.19.0 lib/qonfig/validator/predefined/registry_control_mixin.rb
qonfig-0.18.1 lib/qonfig/validator/predefined/registry_control_mixin.rb
qonfig-0.18.0 lib/qonfig/validator/predefined/registry_control_mixin.rb
qonfig-0.17.0 lib/qonfig/validator/predefined/registry_control_mixin.rb