Sha256: 05edd209489864df56de94ee16566531fecb01abbf9583849410faeecdc8547d

Contents?: true

Size: 744 Bytes

Versions: 11

Compression:

Stored size: 744 Bytes

Contents

class Evil::Client
  # Wraps hash of options with railsy methods [#slice] and [#except]
  #
  # Both methods works on the root level only.
  # Nevertheless, this is sufficient to select/reject a part of the whole
  # options collected from the very root of the client.
  #
  class Options < SimpleDelegator
    # Returns a new hash which include only selected keys
    #
    # @param  [Object, Array<Object>] keys
    # @return [Hash]
    #
    def slice(*keys)
      select { |key| keys.flatten.include? key }
    end

    # Returns a new hash where some keys are excluded from
    #
    # @param  [Object, Array<Object>] keys
    # @return [Hash]
    #
    def except(*keys)
      reject { |key| keys.flatten.include? key }
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
evil-client-3.2.0 lib/evil/client/options.rb
evil-client-3.1.0 lib/evil/client/options.rb
evil-client-3.0.4 lib/evil/client/options.rb
evil-client-3.0.3 lib/evil/client/options.rb
evil-client-3.0.2 lib/evil/client/options.rb
evil-client-3.0.1 lib/evil/client/options.rb
evil-client-3.0.0 lib/evil/client/options.rb
evil-client-2.1.1 lib/evil/client/options.rb
evil-client-2.1.0 lib/evil/client/options.rb
evil-client-2.0.0 lib/evil/client/options.rb
evil-client-1.1.0 lib/evil/client/options.rb