Sha256: dc3a16da58b74ecb2c758910ef04f492f0fb574e8db3a33b9f0ee523c2573f41

Contents?: true

Size: 572 Bytes

Versions: 3

Compression:

Stored size: 572 Bytes

Contents

# frozen_string_literal: true

module HenshinBelt
  module Configuration
    def setup
      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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
henshin-belt-0.0.3 lib/henshin_belt/configuration.rb
henshin-belt-0.0.2 lib/henshin_belt/configuration.rb
henshin-belt-0.0.1 lib/henshin_belt/configuration.rb