Sha256: 67c9dd1c3f830a83266030759ba3bb1778499b790aff5f9642ba517d39994e3c

Contents?: true

Size: 938 Bytes

Versions: 8

Compression:

Stored size: 938 Bytes

Contents

# frozen_string_literal: true

##
# @example
#   ConvenientService::Utils::Hash::Except.call({foo: :bar, baz: :qux}, [:foo])
#
module ConvenientService
  module Utils
    module Hash
      class Except < Support::Command
        ##
        # @!attribute [r] hash
        #   @return [Hash]
        #
        attr_reader :hash

        ##
        # @!attribute [r] keys
        #   @return [Array]
        #
        attr_reader :keys

        ##
        # @param hash [Hash]
        # @param keys [Array]
        # @return [void]
        #
        def initialize(hash, keys)
          @hash = hash
          @keys = keys
        end

        ##
        # @return [Hash]
        #
        # @internal
        #   NOTE: Copied with minimal modifications from:
        #   https://api.rubyonrails.org/classes/Hash.html#method-i-except
        #
        def call
          hash.slice(*hash.keys - keys)
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
convenient_service-0.19.1 lib/convenient_service/utils/hash/except.rb
convenient_service-0.19.0 lib/convenient_service/utils/hash/except.rb
convenient_service-0.18.0 lib/convenient_service/utils/hash/except.rb
convenient_service-0.17.0 lib/convenient_service/utils/hash/except.rb
convenient_service-0.16.0 lib/convenient_service/utils/hash/except.rb
convenient_service-0.15.0 lib/convenient_service/utils/hash/except.rb
convenient_service-0.14.0 lib/convenient_service/utils/hash/except.rb
convenient_service-0.13.0 lib/convenient_service/utils/hash/except.rb