Class: RailsRequest::Payload

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_request/payload.rb

Instance Method Summary collapse

Constructor Details

#initialize(payload) ⇒ Payload

Returns a new instance of Payload.



5
6
7
# File 'lib/rails_request/payload.rb', line 5

def initialize(payload)
  @payload = payload
end

Instance Method Details

#curl_optionsObject



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/rails_request/payload.rb', line 9

def curl_options
  query = params.present? ? "?#{params.to_query}" : nil
  # host and port set during request by before_action
  host = RailsRequest.host
  port = RailsRequest.port
  [
    'curl',
    '-v',
    "--request '#{method}'",
    headers.map { |key, value| "--header '#{key}: #{value}'" },
    "'http://#{host}:#{port}#{path}#{query}'"
  ].flatten.join(" \\\n")
end

#methodObject



27
28
29
# File 'lib/rails_request/payload.rb', line 27

def method
  @payload[:method]
end

#pathObject



23
24
25
# File 'lib/rails_request/payload.rb', line 23

def path
  @payload[:path]
end