Class: Evil::Client::Options

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/evil/client/options.rb

Overview

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.

Instance Method Summary collapse

Instance Method Details

#except(*keys) ⇒ Hash

Returns a new hash where some keys are excluded from

Parameters:

  • keys (Object, Array<Object>)

Returns:

  • (Hash)


23
24
25
# File 'lib/evil/client/options.rb', line 23

def except(*keys)
  reject { |key| keys.flatten.include? key }
end

#slice(*keys) ⇒ Hash

Returns a new hash which include only selected keys

Parameters:

  • keys (Object, Array<Object>)

Returns:

  • (Hash)


14
15
16
# File 'lib/evil/client/options.rb', line 14

def slice(*keys)
  select { |key| keys.flatten.include? key }
end