Sha256: 76fcfc121356e2e8999eb6b6da7afa92cdb192dc77b4c0d5711daf497e917544
Contents?: true
Size: 1.06 KB
Versions: 24
Compression:
Stored size: 1.06 KB
Contents
module ComplexConfig class Proxy < BasicObject def initialize(env = nil) @env = env end def to_s 'ComplexConfig::Proxy' end def inspect "#<#{to_s}>" end def reload ::ComplexConfig::Provider.flush_cache self end def method_missing(name, *args) if name =~ /\?\z/ method_name, name = name, $` exist = ::ComplexConfig::Provider.exist?(name) (class << self; self; end).class_eval do define_method(method_name) do |env = nil| if exist __send__(name, *args) else nil end end end __send__(method_name, *args) else config = ::ComplexConfig::Provider[name] (class << self; self; end).class_eval do define_method(name) do |env = nil| if env ||= @env config[env] || ::ComplexConfig::Settings.new else config end end end __send__(name, *args) end end end end
Version data entries
24 entries across 24 versions & 1 rubygems