Module: CardConnect::Utils
- Included in:
- Service::AuthorizationRequest, Service::AuthorizationResponse, Service::CaptureRequest, Service::CaptureResponse, Service::InquireRequest, Service::InquireResponse, Service::ProfileDeleteRequest, Service::ProfileDeleteResponse, Service::ProfileGetRequest, Service::ProfileGetResponse, Service::ProfilePutRequest, Service::ProfilePutResponse, Service::RefundRequest, Service::RefundResponse, Service::ServiceEndpoint, Service::SettlementStatusRequest, Service::SettlementStatusResponse, Service::VoidRequest, Service::VoidResponse
- Defined in:
- lib/cardconnect/utils.rb
Instance Method Summary collapse
Instance Method Details
#set_attributes(attributes, fields) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/cardconnect/utils.rb', line 3 def set_attributes(attributes, fields) return if attributes.empty? attributes = attributes[0] if attributes.is_a? Array attributes = symbolize_keys(attributes) fields.each do |attr| next unless attributes[attr] send("#{attr}=", attributes[attr]) end end |
#symbolize_keys(hash) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/cardconnect/utils.rb', line 13 def symbolize_keys(hash) symbolized_hash = {} hash.each do |k, v| symbolized_hash[k.to_sym] = v end symbolized_hash end |