class Honeybadger::Config::Mash
Constants
- KEYS
Attributes
config[R]
hash[R]
prefix[R]
Public Class Methods
new(config, prefix: nil, hash: {})
click to toggle source
# File lib/honeybadger/config/ruby.rb, line 6 def initialize(config, prefix: nil, hash: {}) @config = config @prefix = prefix @hash = hash end
Public Instance Methods
to_hash()
click to toggle source
# File lib/honeybadger/config/ruby.rb, line 12 def to_hash hash.to_hash end
Also aliased as: to_h
Private Instance Methods
get(key)
click to toggle source
# File lib/honeybadger/config/ruby.rb, line 60 def get(key) k = key.to_sym return hash[k] if hash.has_key?(k) config.get(k) end
getter?(method_name)
click to toggle source
# File lib/honeybadger/config/ruby.rb, line 49 def getter?(method_name) key = key(method_name) KEYS.any? {|k| k == key } end
key(method_name)
click to toggle source
# File lib/honeybadger/config/ruby.rb, line 54 def key(method_name) parts = [prefix, method_name.to_s.chomp('=')] parts.compact! parts.join('.') end
mash?(method)
click to toggle source
# File lib/honeybadger/config/ruby.rb, line 38 def mash?(method) key = [prefix, method.to_s + '.'].compact.join('.') KEYS.any? {|k| k.start_with?(key) } end
method_missing(method_name, *args, &block)
click to toggle source
Calls superclass method
# File lib/honeybadger/config/ruby.rb, line 21 def method_missing(method_name, *args, &block) m = method_name.to_s if mash?(m) return Mash.new(config, prefix: key(m), hash: hash) elsif setter?(m) return hash.send(:[]=, key(m).to_sym, args[0]) elsif getter?(m) return get(key(m)) end super end
respond_to_missing?(method_name, include_private = false)
click to toggle source
# File lib/honeybadger/config/ruby.rb, line 34 def respond_to_missing?(method_name, include_private = false) true end
setter?(method_name)
click to toggle source
# File lib/honeybadger/config/ruby.rb, line 43 def setter?(method_name) return false unless method_name.to_s =~ /=\z/ key = key(method_name) KEYS.any? {|k| k == key } end