Sha256: 6c51d2a4ebfedd28253853a949ff1cf45b9fc9286e99d23d1a9d4d65c75cd8b7

Contents?: true

Size: 690 Bytes

Versions: 11

Compression:

Stored size: 690 Bytes

Contents

# frozen_string_literal: true

module Glossarist
  module Utilities
    module CommonFunctions
      # Hash#transform_keys is not available in Ruby 2.4
      # so we have to do this ourselves :(
      # symbolize hash keys
      def symbolize_keys(hash)
        result = {}
        hash.each_pair do |key, value|
          result[key.to_sym] = value
        end
        result
      end

      # Hash#slice is not available in Ruby 2.4
      # so we have to do this ourselves :(
      # slice hash keys
      def slice_keys(hash, keys)
        result = {}
        keys.each do |key|
          result[key] = hash[key] if hash.key?(key)
        end
        result
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
glossarist-1.1.0 lib/glossarist/utilities/common_functions.rb
glossarist-1.0.9 lib/glossarist/utilities/common_functions.rb
glossarist-1.0.8 lib/glossarist/utilities/common_functions.rb
glossarist-1.0.7 lib/glossarist/utilities/common_functions.rb
glossarist-1.0.6 lib/glossarist/utilities/common_functions.rb
glossarist-1.0.5 lib/glossarist/utilities/common_functions.rb
glossarist-new-1.0.4 lib/glossarist/utilities/common_functions.rb
glossarist-new-1.0.3 lib/glossarist/utilities/common_functions.rb
glossarist-new-1.0.2 lib/glossarist/utilities/common_functions.rb
glossarist-new-1.0.1 lib/glossarist/utilities/common_functions.rb
glossarist-new-1.0.0 lib/glossarist/utilities/common_functions.rb