Class: Jat::EnumDeepFreeze

Inherits:
Object
  • Object
show all
Defined in:
lib/jat/utils/enum_deep_freeze.rb

Overview

Freezes nested enumerable data

Constant Summary collapse

FREEZES =
{
  Hash => ->(data) { data.each_value(&FREEZE_ENUMS) },
  Array => ->(data) { data.each(&FREEZE_ENUMS) }
}.freeze
FREEZE_ENUMS =
->(value) { call(value) if value.is_a?(Enumerable) }

Class Method Summary collapse

Class Method Details

.call(data) ⇒ Object



13
14
15
16
17
# File 'lib/jat/utils/enum_deep_freeze.rb', line 13

def self.call(data)
  data.freeze
  FREEZES.fetch(data.class).call(data)
  data
end