Sha256: 0c610950c019d57414e653ad40f4ed12b7f37312a1bc4a120ff835fe2a0bac96

Contents?: true

Size: 939 Bytes

Versions: 15

Compression:

Stored size: 939 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

15 entries across 15 versions & 1 rubygems

Version Path
convenient_service-0.12.0 lib/convenient_service/utils/hash/except.rb
convenient_service-0.11.0 lib/convenient_service/utils/hash/except.rb
convenient_service-0.10.1 lib/convenient_service/utils/hash/except.rb
convenient_service-0.10.0 lib/convenient_service/utils/hash/except.rb
convenient_service-0.9.0 lib/convenient_service/utils/hash/except.rb
convenient_service-0.8.0 lib/convenient_service/utils/hash/except.rb
convenient_service-0.7.0 lib/convenient_service/utils/hash/except.rb
convenient_service-0.6.0 lib/convenient_service/utils/hash/except.rb
convenient_service-0.5.0 lib/convenient_service/utils/hash/except.rb
convenient_service-0.4.0 lib/convenient_service/utils/hash/except.rb
convenient_service-0.3.1 lib/convenient_service/utils/hash/except.rb
convenient_service-0.3.0 lib/convenient_service/utils/hash/except.rb
convenient_service-0.2.1 lib/convenient_service/utils/hash/except.rb
convenient_service-0.2.0 lib/convenient_service/utils/hash/except.rb
convenient_service-0.1.0 lib/convenient_service/utils/hash/except.rb