lib/blackbox/hash.rb in blackbox-1.0.0 vs lib/blackbox/hash.rb in blackbox-1.0.1
- old
+ new
@@ -1,9 +1,9 @@
module BB
# Hash utilities.
module Hash
- class << self
+ class << self
# Symbolize all top level keys.
#
# @param [Hash] hash Input hash
# @return [Hash] Output hash (with symbolized keys)
def symbolize_keys(hash)
@@ -29,13 +29,13 @@
# Key delimiter (Default: '.')
# @param [Hash] output (leave this blank)
# @return [Hash] Output hash (flattened)
def flatten_prop_style(input={}, opts={}, output={})
input.each do |key, value|
- key = opts[:prefix].nil? ? "#{key}" : "#{opts[:prefix]}#{opts[:delimiter]||"."}#{key}"
+ key = opts[:prefix].nil? ? "#{key}" : "#{opts[:prefix]}#{opts[:delimiter]||'.'}#{key}"
case value
when ::Hash
- flatten_prop_style(value, {:prefix => key, :delimiter => "."}, output)
+ flatten_prop_style(value, opts.merge({:prefix => key}), output)
when Array
output[key] = value.join(',')
else
output[key] = value
end