Sha256: 4e09c2a816d17365bae89dc5a79af7c09e3bc90abb90a14e399ea920528f6fb0

Contents?: true

Size: 776 Bytes

Versions: 22

Compression:

Stored size: 776 Bytes

Contents

class BigqueryMigration
  class HashUtil
    def self.deep_symbolize_keys(hash)
      if hash.is_a?(Hash)
        hash.map do |key, val|
          new_key = key.to_sym
          new_val = deep_symbolize_keys(val)
          [new_key, new_val]
        end.to_h
      elsif hash.is_a?(Array)
        hash.map do |val|
          deep_symbolize_keys(val)
        end
      else
        hash
      end
    end

    def self.deep_stringify_keys(hash)
      if hash.is_a?(Hash)
        hash.map do |key, val|
          new_key = key.to_s
          new_val = deep_stringify_keys(val)
          [new_key, new_val]
        end.to_h
      elsif hash.is_a?(Array)
        hash.map do |val|
          deep_stringify_keys(val)
        end
      else
        hash
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
bigquery_migration-0.3.2 lib/bigquery_migration/hash_util.rb
bigquery_migration-0.3.1 lib/bigquery_migration/hash_util.rb
bigquery_migration-0.3.0 lib/bigquery_migration/hash_util.rb
bigquery_migration-0.2.2 lib/bigquery_migration/hash_util.rb
bigquery_migration-0.2.1 lib/bigquery_migration/hash_util.rb
bigquery_migration-0.2.0 lib/bigquery_migration/hash_util.rb
bigquery_migration-0.2.0.pre2 lib/bigquery_migration/hash_util.rb
bigquery_migration-0.2.0.pre1 lib/bigquery_migration/hash_util.rb
bigquery_migration-0.1.7 lib/bigquery_migration/hash_util.rb
bigquery_migration-0.1.6 lib/bigquery_migration/hash_util.rb
bigquery_migration-0.1.5 lib/bigquery_migration/hash_util.rb
bigquery_migration-0.1.4 lib/bigquery_migration/hash_util.rb
bigquery_migration-0.1.3 lib/bigquery_migration/hash_util.rb
bigquery_migration-0.1.2 lib/bigquery_migration/hash_util.rb
bigquery_migration-0.1.1 lib/bigquery_migration/hash_util.rb
bigquery_migration-0.1.0 lib/bigquery_migration/hash_util.rb
bigquery_migration-0.1.0.pre6 lib/bigquery_migration/hash_util.rb
bigquery_migration-0.1.0.pre5 lib/bigquery_migration/hash_util.rb
bigquery_migration-0.1.0.pre4 lib/bigquery_migration/hash_util.rb
bigquery_migration-0.1.0.pre3 lib/bigquery_migration/hash_util.rb