Class: Vonage::HTTP::Options

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/vonage/http.rb

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Options

Returns a new instance of Options.

Raises:

  • (ArgumentError)


11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/vonage/http.rb', line 11

def initialize(hash)
  raise ArgumentError, 'hash parameter cannot be empty or nil' if hash == {} || hash.nil?

  @hash = T.let(@hash, T::Hash[Symbol, T.untyped]) if defined? @hash
  @hash = hash

  @hash.each_key do |name|
    next if defined_options.key?(name)

    raise ArgumentError, "#{name.inspect} is not a valid option"
  end
end

Instance Method Details

#set(http) ⇒ Object



25
26
27
28
29
# File 'lib/vonage/http.rb', line 25

def set(http)
  @hash.each do |name, value|
    http.public_send(defined_options.fetch(name), value)
  end
end