Sha256: a4bbedb2b2e1522477cf1cfe0b8c2ff519abf248fa6a00fdaa181c234851b571

Contents?: true

Size: 650 Bytes

Versions: 1

Compression:

Stored size: 650 Bytes

Contents

# frozen_string_literal: true

module DryValidationParser
  module Config
    module Configuration
      def configuration
        yield self
      end

      def define_setting(name, default = nil)
        class_variable_set("@@#{name}", default)

        define_class_method "#{name}=" do |value|
          class_variable_set("@@#{name}", value)
        end

        define_class_method name do
          class_variable_get("@@#{name}")
        end
      end

      private

      def define_class_method(name, &block)
        (class << self; self; end).instance_eval do
          define_method name, &block
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dry_validation_parser-0.1.0 lib/dry_validation_parser/config/configuration.rb