Class: Sofia::Types::Params

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/sofia/types/params.rb

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Params

: (?untyped params) -> void



11
12
13
# File 'lib/sofia/types/params.rb', line 11

def initialize(params = {}) # rubocop:disable Style/OptionHash
  @params = validate_and_normalize(params || {}) #: Hash[String, String]
end

Instance Method Details

#[](key) ⇒ Object

: (untyped key) -> void



16
17
18
# File 'lib/sofia/types/params.rb', line 16

def [](key)
  @params[key.to_s]
end

#[]=(key, value) ⇒ Object

: (untyped key, untyped value) -> void



21
22
23
# File 'lib/sofia/types/params.rb', line 21

def []=(key, value)
  @params[key.to_s] = value.to_s
end

#to_hObject

: -> Hash[String, String]



26
27
28
# File 'lib/sofia/types/params.rb', line 26

def to_h
  @params.dup
end

#to_sObject

: -> String



31
32
33
# File 'lib/sofia/types/params.rb', line 31

def to_s
  URI.encode_www_form(@params)
end