Sha256: 10a5ea9f6c6da8f422df6a7ea49c18efcff6847887f753bc37f9567a377a9fc8
Contents?: true
Size: 794 Bytes
Versions: 2
Compression:
Stored size: 794 Bytes
Contents
# frozen_string_literal: true module ApiResponse class Processor extend Dry::Initializer param :response option :config, default: -> { ApiResponse.config.dup } option :options, default: -> { {} } def self.call(response, options:, config: ApiResponse.config.dup, &block) config = config.dup yield(config) if block config.update(options) new(response, config: config, options: options).call end def call processor = success? ? config.success_processor : config.failure_processor processor.new(response, config: config).call end private def success? case config.adapter when :faraday, :excon response.status.to_i < 400 else response.code.to_i < 400 end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
api-response-presenter-0.0.2 | lib/api_response/processor.rb |
api-response-presenter-0.0.1 | lib/api_response/processor.rb |