Class: T::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/tinternet/request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Request

Returns a new instance of Request.



5
6
7
8
9
10
# File 'lib/tinternet/request.rb', line 5

def initialize(opts = {})
  self.verb    = opts[:verb] || :get
  self.uri     = opts[:uri] 
  self.headers = opts[:headers] || {} 
  self.body    = opts[:body] 
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



3
4
5
# File 'lib/tinternet/request.rb', line 3

def body
  @body
end

#headersObject

Returns the value of attribute headers.



3
4
5
# File 'lib/tinternet/request.rb', line 3

def headers
  @headers
end

#uriObject

Returns the value of attribute uri.



3
4
5
# File 'lib/tinternet/request.rb', line 3

def uri
  @uri
end

#verbObject

Returns the value of attribute verb.



3
4
5
# File 'lib/tinternet/request.rb', line 3

def verb
  @verb
end

Instance Method Details

#auth_header_nameObject



20
# File 'lib/tinternet/request.rb', line 20

def auth_header_name; "Authorization"; end

#authorize(header_value) ⇒ Object



12
13
14
# File 'lib/tinternet/request.rb', line 12

def authorize(header_value)
  headers[auth_header_name] = header_value
end

#authorized?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/tinternet/request.rb', line 16

def authorized?
  headers.include? auth_header_name 
end