Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/carioca/services/configuration.rb
Overview
overwriting Hash class
Direct Known Subclasses
Instance Method Summary collapse
-
#deep_symbolize ⇒ Object
recursively transform Hash keys form String to Symbols come from Rails code exist in Ruby 2.0.
-
#method_missing(name, *args, &block) ⇒ Object
pretty accessor for hash record like ahash => ahash.key r/w accessor.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
pretty accessor for hash record like ahash => ahash.key r/w accessor
45 46 47 48 49 50 51 |
# File 'lib/carioca/services/configuration.rb', line 45 def method_missing(name, *args, &block) if name.to_s =~ /(.+)=$/ self[$1.to_sym] = args.first else self[name.to_sym] end end |
Instance Method Details
#deep_symbolize ⇒ Object
recursively transform Hash keys form String to Symbols come from Rails code exist in Ruby 2.0
33 34 35 36 37 38 39 40 |
# File 'lib/carioca/services/configuration.rb', line 33 def deep_symbolize target = dup target.inject({}) do |memo, (key, value)| value = value.deep_symbolize if value.is_a?(Hash) memo[key.to_sym] = value memo end end |