Class: Porteo::Gateway
- Inherits:
-
Object
- Object
- Porteo::Gateway
- Defined in:
- lib/gateways/gateway.rb
Overview
Base class to implement any gateway needed to connect protocols and sending service gems.
It should not be used by itself but creating a child class which defines specific behavior based on a certain protocol and a gem.
Direct Known Subclasses
Class Method Summary collapse
-
.connection_argument(*argument) ⇒ nil
Set required connection parameters for a specific gateway.
Instance Method Summary collapse
-
#connection_arguments ⇒ Array
Required connection parameters.
-
#init_send(message) ⇒ nil
Initialize the send message process.
-
#initialize(gw_config = {}) ⇒ Gateway
constructor
Create a new instance of a gateway.
-
#send_message(message_sections) ⇒ nil
abstract
Send a message defined in parameter.
Constructor Details
#initialize(gw_config = {}) ⇒ Gateway
Create a new instance of a gateway.
56 57 58 |
# File 'lib/gateways/gateway.rb', line 56 def initialize( gw_config = {} ) @config = gw_config end |
Class Method Details
.connection_argument(*argument) ⇒ nil
Set required connection parameters for a specific gateway. This class method creates a new instance method which overwritte connection_argument.
37 38 39 40 41 |
# File 'lib/gateways/gateway.rb', line 37 def self.connection_argument( *argument ) define_method( :connection_arguments ) do argument end end |
Instance Method Details
#connection_arguments ⇒ Array
Required connection parameters. Its define which fields have to be present in order to send a valid message. This method is overwritten dynamically when a child gateway class is created and self.connection_arguments is called.
49 50 51 |
# File 'lib/gateways/gateway.rb', line 49 def connection_arguments [] end |
#init_send(message) ⇒ nil
Initialize the send message process. Before sending the message it check if all required params are present.
74 75 76 |
# File 'lib/gateways/gateway.rb', line 74 def init_send( ) ( ) end |
#send_message(message_sections) ⇒ nil
This method has to be overwritten.
Send a message defined in parameter
66 67 68 |
# File 'lib/gateways/gateway.rb', line 66 def ( ) raise Exception, "Gateway Error. This method has to be overwritten. You are trying to send a message with a generic gateway." end |