Module: AxeCuprite::DeepFreeze

Defined in:
lib/axe/cuprite/results.rb

Overview

Recursively freezes a parsed-JSON tree (hashes/arrays of scalars) so the read-only wrappers below can hand out ‘raw`/`to_h` without a caller being able to mutate internal state (which, via memoization, could otherwise desync `violations`/`incomplete` from `raw`). Idempotent and cheap on the slimmed payload we carry back.

Class Method Summary collapse

Class Method Details

.call(obj) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/axe/cuprite/results.rb', line 12

def call(obj)
  case obj
  when Hash
    obj.each { |k, v| [k, v].each { |o| call(o) } }
  when Array
    obj.each { |v| call(v) }
  end
  obj.freeze
end