Sha256: 0ea0e24b48a6b7656e3181ef315560bbca0f13219e61b8a3e6948b967950bcb3

Contents?: true

Size: 733 Bytes

Versions: 8

Compression:

Stored size: 733 Bytes

Contents

# frozen_string_literal: true

#
# Abstraction over WebMock to reduce duplication
#
# @author Mikael Henriksson <mikael@zoolutions.se>
# @since 0.1.0
#
module StubRequests
  #
  # Provides convenience methods for hashes
  #
  # @author Mikael Henriksson <mikael@zoolutions.se>
  #
  module HashUtil
    #
    # Removes all entries with nil values (first level only)
    #
    # @param [Hash] options the hash to compact
    #
    # @return [Hash, nil] Returns
    #
    # @yieldparam [Hash] compacted the hash without nils
    # @yieldreturn [void]
    def self.compact(options)
      return if options.blank?

      compacted = options.delete_if { |_, val| val.blank? }
      yield compacted if compacted.present?
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
stub_requests-0.1.9 lib/stub_requests/hash_util.rb
stub_requests-0.1.8 lib/stub_requests/hash_util.rb
stub_requests-0.1.7 lib/stub_requests/hash_util.rb
stub_requests-0.1.6 lib/stub_requests/hash_util.rb
stub_requests-0.1.5 lib/stub_requests/hash_util.rb
stub_requests-0.1.4 lib/stub_requests/hash_util.rb
stub_requests-0.1.3 lib/stub_requests/hash_util.rb
stub_requests-0.1.2 lib/stub_requests/hash_util.rb