Sha256: 42a6120f4a970ec3dc60ce50ff573fe8f8420d5c20c66dd59996636e04b7d122
Contents?: true
Size: 989 Bytes
Versions: 47
Compression:
Stored size: 989 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) @response = response @klass = klass @key = key if @response.success? @result = if data.is_a?(Array) data.map do |doc| @klass.new(doc) end else @klass.new(data) end 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
47 entries across 47 versions & 2 rubygems