class Honeybadger::Config::Mash
Constants
- KEYS
Attributes
Public Class Methods
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
Source
# File lib/honeybadger/config/ruby.rb, line 12 def to_hash hash.to_hash end
Also aliased as: to_h
Private Instance Methods
Source
# File lib/honeybadger/config/ruby.rb, line 65 def get(key) k = key.to_sym return hash[k] if hash.has_key?(k) config.get(k) end
Source
# File lib/honeybadger/config/ruby.rb, line 54 def getter?(method_name) key = key(method_name) KEYS.any? {|k| k == key } end
Source
# File lib/honeybadger/config/ruby.rb, line 59 def key(method_name) parts = [prefix, method_name.to_s.chomp('=')] parts.compact! parts.join('.') end
Source
# File lib/honeybadger/config/ruby.rb, line 43 def mash?(method) key = [prefix, method.to_s + '.'].compact.join('.') KEYS.any? {|k| k.start_with?(key) } end
Source
# 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
Calls superclass method
Source
# File lib/honeybadger/config/ruby.rb, line 34 def respond_to_missing?(method_name, include_private = false) m = method_name.to_s if mash?(m) || setter?(m) || getter?(m) true else super end end
Calls superclass method
Source
# File lib/honeybadger/config/ruby.rb, line 48 def setter?(method_name) return false unless method_name.to_s =~ /=\z/ key = key(method_name) KEYS.any? {|k| k == key } end