Method: Liquid::Utils.hash_inspect

Defined in:
lib/liquid/utils.rb

.hash_inspect(hash, seen = {}) ⇒ Object



155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/liquid/utils.rb', line 155

def self.hash_inspect(hash, seen = {})
  if seen[hash.object_id]
    return "{...}"
  end
  seen[hash.object_id] = true

  str = +"{"
  first = true
  hash.each do |key, value|
    if first
      first = false
    else
      str << ", "
    end

    key_str = inspect(key, seen)
    str << key_str
    str << "=>"

    value_str = inspect(value, seen)
    str << value_str
  end
  str << "}"
  str
ensure
  seen.delete(hash.object_id)
end