class Render::Extensions::DottableHash

Public Class Methods

initialize_element(value) click to toggle source
# File lib/render/extensions/dottable_hash.rb, line 20
def initialize_element(value)
  case value
  when Hash
    new(value)
  when Array
    values = value.collect do |v|
      initialize_element(v)
    end
    SymbolizableArray.new(values)
  else
    value
  end
end
new(element_to_hash = {}) click to toggle source
Calls superclass method
# File lib/render/extensions/dottable_hash.rb, line 8
def new(element_to_hash = {})
  symbolize_hash = SymbolizableHash.new.merge!(element_to_hash)
  symbolize_hash.symbolize_keys!
  hash = super().merge!(symbolize_hash)

  hash.each do |key, value|
    hash[key] = initialize_element(value)
  end

  hash
end

Public Instance Methods

[](key) click to toggle source
Calls superclass method
# File lib/render/extensions/dottable_hash.rb, line 41
def [](key)
  key = key.to_sym
  super
end
[]=(key, value) click to toggle source
Calls superclass method
# File lib/render/extensions/dottable_hash.rb, line 35
def []=(key, value)
  key = key.to_sym
  value = self.class.initialize_element(value)
  super
end
delete(key) click to toggle source
Calls superclass method
# File lib/render/extensions/dottable_hash.rb, line 46
def delete(key)
  key = key.to_sym
  super
end
fetch(key, *args) click to toggle source
Calls superclass method
# File lib/render/extensions/dottable_hash.rb, line 75
def fetch(key, *args)
  key = key.to_sym
  super
end
has_key?(key) click to toggle source
Calls superclass method
# File lib/render/extensions/dottable_hash.rb, line 51
def has_key?(key)
  super(key.to_sym)
end
merge(other_hash) click to toggle source
Calls superclass method
# File lib/render/extensions/dottable_hash.rb, line 60
def merge(other_hash)
  other_hash = SymbolizableHash.new().merge!(other_hash)
  super(other_hash.recursively_symbolize_keys!)
end
merge!(other_hash) click to toggle source
Calls superclass method
# File lib/render/extensions/dottable_hash.rb, line 55
def merge!(other_hash)
  other_hash = SymbolizableHash.new().merge!(other_hash)
  super(other_hash.recursively_symbolize_keys!)
end
method_missing(method, *arguments) click to toggle source
Calls superclass method
# File lib/render/extensions/dottable_hash.rb, line 65
def method_missing(method, *arguments)
  if method.match(/\=$/)
    self[method.to_s.chop] = arguments.first
  elsif has_key?(method)
    self[method]
  else
    super
  end
end