Module: Lipwa::Gateways
- Extended by:
- Dry::Container::Mixin
- Defined in:
- lib/lipwa/gateways.rb,
lib/lipwa/gateways/mpesa.rb,
lib/lipwa/gateways/mpesa/auth.rb,
lib/lipwa/gateways/mpesa/security_credential.rb
Overview
Dry::Container-based registry of provider gateways. Providers register their Gateway subclass once (typically at load time); consumers look them up by name instead of hardcoding gateway class names — see Lipwa.gateway.
Defined Under Namespace
Classes: Mpesa
Class Method Summary collapse
Class Method Details
.register(key, gateway_class) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/lipwa/gateways.rb', line 16 def register(key, gateway_class) unless gateway_class.is_a?(Class) && gateway_class <= Lipwa::Gateway raise Lipwa::ConfigurationError, "#{gateway_class} must be a subclass of Lipwa::Gateway" end super(key.to_sym, memoize: true) { gateway_class.new } end |