Class: Gitlab::ImportExport::HashUtil

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/import_export/hash_util.rb

Class Method Summary collapse

Class Method Details

.deep_symbolize_array!(array) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/gitlab/import_export/hash_util.rb', line 6

def self.deep_symbolize_array!(array)
  return if array.blank?

  array.map! do |hash|
    hash.deep_symbolize_keys!

    yield(hash) if block_given?

    hash
  end
end

.deep_symbolize_array_with_date!(array) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/gitlab/import_export/hash_util.rb', line 18

def self.deep_symbolize_array_with_date!(array)
  self.deep_symbolize_array!(array) do |hash|
    hash.select { |k, _v| k.to_s.end_with?('_date') }.each do |key, value|
      hash[key] = Time.zone.parse(value)
    end
  end
end