Class: Julewire::Core::Serialization::DeepFreeze

Inherits:
Object
  • Object
show all
Defined in:
lib/julewire/core/serialization/deep_freeze.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(max_depth, trust_frozen:) ⇒ DeepFreeze

Returns a new instance of DeepFreeze.



15
16
17
18
# File 'lib/julewire/core/serialization/deep_freeze.rb', line 15

def initialize(max_depth, trust_frozen:)
  @max_depth = max_depth
  @trust_frozen = trust_frozen
end

Class Method Details

.call(value, max_depth: Core::NORMALIZATION_MAX_DEPTH, trust_frozen: false) ⇒ Object



10
11
12
# File 'lib/julewire/core/serialization/deep_freeze.rb', line 10

def call(value, max_depth: Core::NORMALIZATION_MAX_DEPTH, trust_frozen: false)
  new(max_depth, trust_frozen: trust_frozen).call(value)
end

Instance Method Details

#call(value) ⇒ Object



20
21
22
# File 'lib/julewire/core/serialization/deep_freeze.rb', line 20

def call(value)
  traverse(value) { |root, depth| freeze_value(root, depth) }
end