Sha256: a7109de2ae3ab19114aab1a8e75594edc761b4aa31e86bf8c3be16bd35d55af1
Contents?: true
Size: 733 Bytes
Versions: 1
Compression:
Stored size: 733 Bytes
Contents
require 'deterministic' require 'dry-struct' require 'dry-types' require 'json' module Salestation class Web < Module module Types include Dry::Types.module end def initialize(errors: {}) @error_mapper = ErrorMapper.new(errors) end def included(base) error_mapper = @error_mapper base.class_eval do const_set :Responses, Salestation::Web::Responses define_method(:process) do |response| result = response.map_err(error_mapper.map).value status result.status json JSON.dump(result.body) end end end end end require_relative './web/responses' require_relative './web/error_mapper' require_relative './result_helper'
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
salestation-0.1.0 | lib/salestation/web.rb |