Class Method Details

.convert(value) ⇒ Object

.deep_freeze(value) ⇒ void

This method returns an undefined value.

Duplicate and deeply freeze a given data structure

Parameters:

value(Object)
—

The structure to freeze

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

# File 'lib/facter/util/values.rb', line 14defdeep_freeze(value)casevaluewhenNumeric,Symbol,TrueClass,FalseClass,NilClass# These are immutable values, we can safely ignore them
valuewhenStringvalue.dup.freezewhenArrayvalue.mapdo|entry|deep_freeze(entry)end.freezewhenHashvalue.inject({})do|hash,(key,value)|hash[deep_freeze(key)]=deep_freeze(value)hashend.freezeelseraiseDeepFreezeError,"Cannot deep freeze #{value}:#{value.class}"endend

Instance Method Details

#convert(value) ⇒ Object(private)

#deep_freeze(value) ⇒ void(private)

This method returns an undefined value.

Duplicate and deeply freeze a given data structure

Parameters:

value(Object)
—

The structure to freeze

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

# File 'lib/facter/util/values.rb', line 14defdeep_freeze(value)casevaluewhenNumeric,Symbol,TrueClass,FalseClass,NilClass# These are immutable values, we can safely ignore them
valuewhenStringvalue.dup.freezewhenArrayvalue.mapdo|entry|deep_freeze(entry)end.freezewhenHashvalue.inject({})do|hash,(key,value)|hash[deep_freeze(key)]=deep_freeze(value)hashend.freezeelseraiseDeepFreezeError,"Cannot deep freeze #{value}:#{value.class}"endend