Sha256: 227d52d0953cf384bc44f319c72da1950083e7415e54a627f9956a6a1ea45e17
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
module Econfig class Configuration attr_accessor :default_write_backend def backends @backends ||= BackendCollection.new end def fetch(key) self[key] or raise Econfig::NotFound, "configuration key '#{key}' is not set" end def [](key) backends.each do |backend| value = backend.get(key.to_s) return value if value end nil end def []=(backend_name = default_write_backend, key, value) raise ArgumentError, "no backend given" unless backend_name if backend = backends[backend_name] backend.set(key.to_s, value) else raise KeyError, "#{backend_name} is not set" end end def method_missing(name, *args) if respond_to?(name) raise ArgumentError, "too many arguments (#{args.length} for 0)" if args.length > 0 fetch(name) else super end end def respond_to_missing?(name, *) name = name.to_s not(name.end_with?("=") or name.end_with?("!") or name.end_with?("?")) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
econfig-1.0.1 | lib/econfig/configuration.rb |