lib/ecoportal/api/common/batch_response.rb in ecoportal-api-0.2.0 vs lib/ecoportal/api/common/batch_response.rb in ecoportal-api-0.2.1

- old
+ new

@@ -1,15 +1,28 @@ module Ecoportal module API module Common class BatchResponse - attr_reader :status, :body - def initialize(status, body) + attr_reader :status, :body, :result + def initialize(status, body, result = nil) @status = status @body = body + @result = result end def success? (0..299).include?(status) + 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