Class: WisperNext::CastToOptions Private

Inherits:
Object
  • Object
show all
Defined in:
lib/wisper_next/cast_to_options.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Class Method Summary collapse

Class Method Details

.call(arguments) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Examples:


def call(*args)
  CastToOptions.call(args)
end

call(:strict, :async: false) # => { strict: true, async: false }


12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/wisper_next/cast_to_options.rb', line 12

def self.call(arguments)
  arguments.reduce({}) do |memo, item|
    case item
    when Symbol
      memo[item] = true
    when Hash
      memo.merge!(item)
    else
      raise(ArgumentError, "Unsupported option: #{item.inspect} (#{item.class.name})")
    end

    memo
  end
end