Class: Riddl::Utils::Description::Call

Inherits:
Implementation show all
Defined in:
lib/ruby/riddl/utils/description.rb

Instance Method Summary collapse

Methods inherited from Implementation

#headers, #initialize, #status

Constructor Details

This class inherits a constructor from Riddl::Implementation

Instance Method Details

#responseObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ruby/riddl/utils/description.rb', line 15

def response
  client = Riddl::Client.new @a[3]

  path = client.resource "/" + @a[4]
  @status, result, headers = if @a[0].nil?
    path.request @m => [ Riddl::Header.new("RIDDL_DECLARATION_RESOURCE", @a[2]), Riddl::Header.new("RIDDL-DECLARATION-PATH", @a[1]) ] + @h.map{|a,b| Riddl::Header.new(a,b)} + @p
  else 
    path.request @m => [ Riddl::Header.new("RIDDL_DECLARATION_RESOURCE", @a[2]), Riddl::Header.new("RIDDL-DECLARATION-PATH", @a[1]) ] + @a[0].headers.map{|a,b| Riddl::Header.new(a,b)} + @a[0].response
  end
  headers.each do |k,v|
    @headers << Riddl::Header.new(k,v) unless ["CONTENT_TYPE", "CONTENT_DISPOSITION", "RIDDL_TYPE", "CONTENT_ID", "CONTENT_LENGTH", "CONNECTION", "SERVER"].include?(k)
  end
  result
end