Class: AchClient::Transformer
- Inherits:
-
Object
- Object
- AchClient::Transformer
- Defined in:
- lib/ach_client/providers/abstract/transformer.rb
Overview
Transforms between client class and the strings that the provider expects For example, the TransactionType classes are serialized as ‘C’ or ‘D’ for AchWorks
Direct Known Subclasses
AchWorks::AccountTypeTransformer, AchWorks::TransactionTypeTransformer, ICheckGateway::AccountTypeTransformer, Sftp::AccountTypeTransformer, Sftp::TransactionTypeTransformer
Class Method Summary collapse
-
.deserialize_provider_value(string) ⇒ Class
Convert provider’s string representation to AchClient class representation AchClient::AccountTypes::Savings.
-
.serialize_to_provider_value(type) ⇒ String
Convert client class to string representation used by provider.
-
.transformer ⇒ Hash {String => Class}
Mapping of classes to strings, to be overridden.
Class Method Details
.deserialize_provider_value(string) ⇒ Class
Convert provider’s string representation to AchClient class
representation
AchClient::AccountTypes::Savings
14 15 16 17 18 |
# File 'lib/ach_client/providers/abstract/transformer.rb', line 14 def self.deserialize_provider_value(string) self.transformer[string] or raise( "Unknown #{self} string #{string}" ) end |
.serialize_to_provider_value(type) ⇒ String
Convert client class to string representation used by provider
24 25 26 27 28 29 30 |
# File 'lib/ach_client/providers/abstract/transformer.rb', line 24 def self.serialize_to_provider_value(type) self.transformer.find do |_, v| type <= v end.try(:first) or raise( "type must be one of #{self.transformer.values.join(', ')}" ) end |
.transformer ⇒ Hash {String => Class}
Mapping of classes to strings, to be overridden
34 35 36 |
# File 'lib/ach_client/providers/abstract/transformer.rb', line 34 def self.transformer raise AbstractMethodError end |