Sha256: 58cc3f395d69667e002e2ff9aa9d14fce043fa4cf73d6481f2f509131499ebbe
Contents?: true
Size: 738 Bytes
Versions: 1
Compression:
Stored size: 738 Bytes
Contents
require "simple_configuration/version" module SimpleConfiguration MissingConfigurationError = Class.new(RuntimeError) MISSING_VALUE = '__missing_value__' def config(config_name, default_value = MISSING_VALUE, &default_value_blk) if default_value_blk define_method(config_name) { |*args| instance_exec(*args, &default_value_blk) } elsif default_value != MISSING_VALUE define_method(config_name) { |*_| default_value } else define_method(config_name) { |*_| raise(MissingConfigurationError, config_name) } end define_singleton_method(config_name) do |value = nil, &blk| define_method(config_name) do |*args| blk ? instance_exec(*args, &blk) : value end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
simple_configuration-0.1.0 | lib/simple_configuration.rb |