module Voom::Presenters::WebClient::Helpers::ExpandHash

Public Instance Methods

expand_hash(h) click to toggle source
# File lib/voom/presenters/web_client/helpers/expand_hash.rb, line 6
def expand_hash(h)
  HashExt::Traverse.traverse(h.to_h) do |k,v|
    if !v.is_a?(Array) && v.respond_to?(:to_h)
      v = v.is_a?(OpenStruct) ? expand_hash(v.to_h) : v.to_h
    elsif v.is_a?(Array)
      v = v.map {|v| v.is_a?(OpenStruct) ? expand_hash(v.to_h) : v}
    elsif v.respond_to?(:to_hash)
      v = v.to_hash
    end
    [k,v]
  end
end