Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/carioca/services/config.rb

Overview

monkey patching of Hash

Direct Known Subclasses

Carioca::Services::Config::Settings

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/carioca/services/config.rb', line 13

def method_missing(name, *args)
  if name.to_s =~ /(.+)=$/
    self[Regexp.last_match(1).to_sym] = args.first
  else
    self[name.to_sym]
  end
end

Instance Method Details

#deep_symbolizeObject



5
6
7
8
9
10
11
# File 'lib/carioca/services/config.rb', line 5

def deep_symbolize
  target = dup
  target.each_with_object({}) do |(key, value), memo|
    value = value.deep_symbolize if value.is_a?(Hash)
    memo[key.to_sym] = value
  end
end