Class: ProviderGateway
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ProviderGateway
- Defined in:
- app/models/provider_gateway.rb
Instance Method Summary collapse
- #human_fields_mapping ⇒ Object
-
#human_fields_mapping=(value) ⇒ Object
METHODS.
- #map(account, raw_fields) ⇒ Object
Instance Method Details
#human_fields_mapping ⇒ Object
23 24 25 26 |
# File 'app/models/provider_gateway.rb', line 23 def human_fields_mapping return '' if self.fields_mapping.blank? self.fields_mapping.collect{|k,v| "#{k}=#{v}"}.join("\n") end |
#human_fields_mapping=(value) ⇒ Object
METHODS
18 19 20 21 |
# File 'app/models/provider_gateway.rb', line 18 def human_fields_mapping=(value) self.fields_mapping = value.gsub("\r", '').split("\n").map{|x| x.split('=')} self.fields_mapping = Hash[*self.fields_mapping.select{|x| x.length > 1}.flatten] end |
#map(account, raw_fields) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/models/provider_gateway.rb', line 28 def map(account, raw_fields) fields = {} if !account.blank? && !account_mapping.blank? fields[account_mapping] = account end unless raw_fields.blank? unless fields_mapping.blank? fields_mapping.each do |k, v| fields[v] = raw_fields[k] unless raw_fields[k].blank? end else fields.merge!(raw_fields) end end fields end |