class Ecoportal::API::Common::WrappedResponse

Attributes

response[R]
result[R]

Public Class Methods

new(response, klass) click to toggle source
# File lib/ecoportal/api/common/wrapped_response.rb, line 9
def initialize(response, klass)
  @response = response
  @klass    = klass

  if @response.success?
    @result =
      if @response.body.is_a?(Array)
        @response.body.map do |doc|
          @klass.new(doc)
        end
      else
        @klass.new(@response.body)
      end
  end
end

Public Instance Methods

body() click to toggle source
# File lib/ecoportal/api/common/wrapped_response.rb, line 25
def body
  response.body.to_s
end
each() { |doc| ... } click to toggle source
# File lib/ecoportal/api/common/wrapped_response.rb, line 29
def each
  [*result].each do |doc|
    yield doc
  end
end
print_pretty() click to toggle source
status() click to toggle source
# File lib/ecoportal/api/common/wrapped_response.rb, line 35
def status
  response.status.code
end
success?() click to toggle source
# File lib/ecoportal/api/common/wrapped_response.rb, line 39
def success?
  response.success?
end