Sha256: b662a3b9f10ac60b01f5247a59558facd7660f54f00a237fcec56737a81ac147
Contents?: true
Size: 1021 Bytes
Versions: 9
Compression:
Stored size: 1021 Bytes
Contents
module Ecoportal module API module Common module Content class WrappedResponse < Ecoportal::API::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
9 entries across 9 versions & 1 rubygems