Sha256: a57fb9d950a29101a9ccb72169c90a3c97d5dd2c92e9eba28b4595e982b88259

Contents?: true

Size: 569 Bytes

Versions: 8

Compression:

Stored size: 569 Bytes

Contents

# frozen_string_literal: true

module SunSword
  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

8 entries across 8 versions & 1 rubygems

Version Path
sun-sword-0.0.9 lib/sun_sword/configuration.rb
sun-sword-0.0.8 lib/sun_sword/configuration.rb
sun-sword-0.0.7 lib/sun_sword/configuration.rb
sun-sword-0.0.6 lib/sun_sword/configuration.rb
sun-sword-0.0.5 lib/sun_sword/configuration.rb
sun-sword-0.0.4 lib/sun_sword/configuration.rb
sun-sword-0.0.3 lib/sun_sword/configuration.rb
sun-sword-0.0.2 lib/sun_sword/configuration.rb