Sha256: ad23c6a18b5dd9b23d7ab262934062714009d24e33a236626b942811c8051781

Contents?: true

Size: 617 Bytes

Versions: 3

Compression:

Stored size: 617 Bytes

Contents

module Ecoportal
  module API
    module Common
      class BatchResponse
        attr_reader :status, :body, :result
        def initialize(status, body, result = nil)
          @status = HTTP::Response::Status.new(status)
          @body   = body
          @result = result
        end
        def success?
          status.success?
        end
        def each
          [*@result].each do |doc|
            yield doc
          end
        end
        def print
          if success?
            each(&:print)
          else
            puts "Request failed."
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ecoportal-api-0.3.8 lib/ecoportal/api/common/batch_response.rb
ecoportal-api-0.3.6 lib/ecoportal/api/common/batch_response.rb
ecoportal-api-0.3.5 lib/ecoportal/api/common/batch_response.rb