Sha256: dbd08bcdcc95b968b4f467ab7dd46e3c60cd6be8b6c5104527504311727fa577
Contents?: true
Size: 1005 Bytes
Versions: 7
Compression:
Stored size: 1005 Bytes
Contents
module Ecoportal module API module Common module Content class WrappedResponse < Common::WrappedResponse include Enumerable attr_reader :response, :result def initialize(response, klass, key: nil) # rubocop:disable Lint/MissingSuper @response = response @klass = klass @key = key return unless @response.success? @result = if data.is_a?(Array) data.map do |doc| @klass.new(doc) end else @klass.new(data) end end def data return @data if instance_variable_defined?(:@data) @data = (response.body || {})["data"] @data = @data[@key] if @key && @data @data end def body data.to_s end end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems