Class: Requester::Request

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ Request

Returns a new instance of Request.



9
10
11
12
13
14
15
16
# File 'lib/requester/request.rb', line 9

def initialize(request)
  @request = request
  @config = Requester::Config
  @json = {
    path: request.fullpath,
    method: request.method
  }
end

Class Method Details

.generate(request) ⇒ Object



5
6
7
# File 'lib/requester/request.rb', line 5

def self.generate(request)
  new(request).json
end

Instance Method Details

#jsonObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/requester/request.rb', line 18

def json
  @json.tap do |json|
    json[:request_parameters] = @request.request_parameters if @request.request_parameters
    json[:query_string] = @request.query_string if @request.query_string
    json[:media_type] = @request.media_type if @request.media_type

    Requester::Config.additional_request_attributes.each do |attr|
      json[attr] = @request.public_send(attr)
    end
  end
end