Sha256: 16fa4801c6662606b66f761428c8c49da7f2c7e005e2ac51029be220181b9569

Contents?: true

Size: 902 Bytes

Versions: 9

Compression:

Stored size: 902 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 result.body
        end
      end
    end
  end
end

require_relative './web/extractors'
require_relative './web/responses'
require_relative './web/error_mapper'
require_relative './result_helper'
require_relative './web/active_record_connection_management'
require_relative './web/request_logger'
require_relative './web/statsd_middleware'

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
salestation-0.11.0 lib/salestation/web.rb
salestation-0.10.0 lib/salestation/web.rb
salestation-0.9.0 lib/salestation/web.rb
salestation-0.8.0 lib/salestation/web.rb
salestation-0.7.0 lib/salestation/web.rb
salestation-0.6.0 lib/salestation/web.rb
salestation-0.5.0 lib/salestation/web.rb
salestation-0.4.0 lib/salestation/web.rb
salestation-0.3.0 lib/salestation/web.rb