Class: Payments::Client::Gateway

Inherits:
Object
  • Object
show all
Defined in:
lib/payments/client/gateway.rb

Instance Method Summary collapse

Constructor Details

#initialize(adapter, config, *adapter_options, connection: nil) ⇒ Gateway

Returns a new instance of Gateway.



9
10
11
12
13
14
# File 'lib/payments/client/gateway.rb', line 9

def initialize(adapter, config, *adapter_options, connection: nil)
  @config = config
  @adapter = adapter
  @adapter_options = adapter_options
  @connection = connection
end

Instance Method Details

#with_middleware(keep: true, response: nil) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/payments/client/gateway.rb', line 28

def with_middleware(keep: true, response: nil)
  new_connection = connection.dup
  new_connection.build(keep: keep) do |builder|
    Array(response).each do |middleware|
      builder.response middleware
    end
  end

  self.class.new(
    @adapter,
    @config,
    *@adapter_options,
    connection: new_connection,
  )
end