Sha256: a19c562a6ae0487fcde146c0c3e6fc65dcac9521146ed2bc91685aa333deaaca
Contents?: true
Size: 892 Bytes
Versions: 2
Compression:
Stored size: 892 Bytes
Contents
module Ecoportal module API module Common class WrappedResponse attr_reader :response, :result 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 def each [*@result].each do |doc| yield doc end end def success? @response.success? end def print if success? @result&.map(&:print) else puts "Request failed." end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ecoportal-api-0.1.1 | lib/ecoportal/api/common/wrapped_response.rb |
ecoportal-api-0.1.0 | lib/ecoportal/api/common/wrapped_response.rb |