Class: Schemacop::V2::Dupper

Inherits:
Object
  • Object
show all
Defined in:
lib/schemacop/v2/dupper.rb

Class Method Summary collapse

Class Method Details

.dup_data(data) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/schemacop/v2/dupper.rb', line 3

def self.dup_data(data)
  if data.is_a?(Hash)
    data = data.dup

    data.each do |key, value|
      data[key] = dup_data(value)
    end

    return data
  elsif data.is_a?(Array)
    return data.map { |value| dup_data(value) }
  else
    return data
  end
end