Sha256: defc89efdc7acd817a5aaaea1584174a2ae3d80fdd12a445f620eaf3acf3c260

Contents?: true

Size: 487 Bytes

Versions: 1

Compression:

Stored size: 487 Bytes

Contents

require "simple_configurable/version"

module SimpleConfigurable
  def self.with(*attrs)
    configuration_class = Class.new do
      attr_accessor *attrs
    end

    class_methods = Module.new do
      define_method :config do
        @config ||= configuration_class.new
      end

      def configure
        yield config
      end
    end

    Module.new do
      singleton_class.send :define_method, :included do |base|
        base.extend class_methods
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
simple_configurable-1.0.0 lib/simple_configurable.rb