module SimpleConfigurable

Constants

VERSION

Public Class Methods

with(*attrs) click to toggle source
# File lib/simple_configurable.rb, line 4
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

Public Instance Methods

configure() { |config| ... } click to toggle source
# File lib/simple_configurable.rb, line 14
def configure
  yield config
end