class CoolHash
Public Class Methods
new(hash)
click to toggle source
# File lib/dodiez.rb, line 4 def initialize(hash) @hash = hash end
Public Instance Methods
[](key)
click to toggle source
# File lib/dodiez.rb, line 8 def [](key) if needed_type?(key) @hash[key] ? @hash[key] : @hash[key.to_sym] || @hash[key.to_s] else @hash[key] end end
Private Instance Methods
needed_type?(key)
click to toggle source
# File lib/dodiez.rb, line 17 def needed_type?(key) key.class == String || key.class == Symbol end