Sha256: ee79e4be06c1b79cb4b23706c54d93fbd085fc95ec58dec926935983b7618ca4

Contents?: true

Size: 636 Bytes

Versions: 6

Compression:

Stored size: 636 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 pretty_print
          if success?
            each(&:pretty_print)
          else
            puts "Request failed."
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ecoportal-api-0.7.4 lib/ecoportal/api/common/batch_response.rb
ecoportal-api-0.7.3 lib/ecoportal/api/common/batch_response.rb
ecoportal-api-0.7.2 lib/ecoportal/api/common/batch_response.rb
ecoportal-api-0.7.1 lib/ecoportal/api/common/batch_response.rb
ecoportal-api-0.7.0 lib/ecoportal/api/common/batch_response.rb
ecoportal-api-0.6.0 lib/ecoportal/api/common/batch_response.rb