Class: Vonage::HTTP::Options
- Inherits:
-
Object
- Object
- Vonage::HTTP::Options
- Extended by:
- T::Sig
- Defined in:
- lib/vonage/http.rb
Instance Method Summary collapse
-
#initialize(hash) ⇒ Options
constructor
A new instance of Options.
- #set(http) ⇒ Object
Constructor Details
#initialize(hash) ⇒ Options
Returns a new instance of Options.
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 .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(.fetch(name), value) end end |