Module: Sinja::ConfigUtils

Included in:
Config, RolesConfig
Defined in:
lib/sinja/config.rb

Instance Method Summary collapse

Instance Method Details

#deep_copy(c) ⇒ Object


14
15
16
# File 'lib/sinja/config.rb', line 14

def deep_copy(c)
  Marshal.load(Marshal.dump(c))
end

#deep_freeze(c) ⇒ Object


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/sinja/config.rb', line 18

def deep_freeze(c)
  if c.respond_to?(:default_proc)
    c.default_proc = nil
  end

  if c.respond_to?(:values)
    c.each_value do |i|
      if i.is_a?(Hash)
        deep_freeze(i)
      else
        i.freeze
      end
    end
  end

  c.freeze
end