Class: Requests::PreparedRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/requests/models.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method:, url:, headers: nil, body: nil) ⇒ PreparedRequest

Returns a new instance of PreparedRequest.



8
9
10
11
12
13
# File 'lib/requests/models.rb', line 8

def initialize(method:, url:, headers: nil, body: nil)
  @method = method
  @url = url
  @headers = headers
  @body = body
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



7
8
9
# File 'lib/requests/models.rb', line 7

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



7
8
9
# File 'lib/requests/models.rb', line 7

def headers
  @headers
end

#methodObject (readonly)

Returns the value of attribute method.



7
8
9
# File 'lib/requests/models.rb', line 7

def method
  @method
end

#urlObject (readonly)

Returns the value of attribute url.



7
8
9
# File 'lib/requests/models.rb', line 7

def url
  @url
end

Instance Method Details

#[](key) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/requests/models.rb', line 14

def [](key)
  case key.to_sym
  when :method then @method
  when :url then @url
  when :headers then @headers
  when :body then @body
  end
end

#to_hObject



22
23
24
# File 'lib/requests/models.rb', line 22

def to_h
  { method: @method, url: @url, headers: @headers, body: @body }
end