Class: Gateway::PostNotification
- Inherits:
-
Object
- Object
- Gateway::PostNotification
- Defined in:
- lib/gateway/post_notification.rb
Overview
Class who handles Gateway post notification XML
Class Method Summary collapse
-
.ParseNotification(xml) ⇒ Hash<Symbol, String>
This method parse the Xml sent by Gateway when notify a change in a transaction.
-
.to_underscore(camel_case_string) ⇒ Object
Converts a string in Camel Case format to lower case with underscore.
Class Method Details
.ParseNotification(xml) ⇒ Hash<Symbol, String>
This method parse the Xml sent by Gateway when notify a change in a transaction.
12 13 14 15 16 17 18 |
# File 'lib/gateway/post_notification.rb', line 12 def self.ParseNotification(xml) nori = Nori.new(:convert_tags_to => lambda { |tag| PostNotification.to_underscore(tag).to_sym }) xml_hash = nori.parse(CGI::unescapeHTML(xml)) return xml_hash end |
.to_underscore(camel_case_string) ⇒ Object
Converts a string in Camel Case format to lower case with underscore.
24 25 26 27 28 29 30 |
# File 'lib/gateway/post_notification.rb', line 24 def self.to_underscore(camel_case_string) return camel_case_string.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2'). gsub(/([a-z\d])([A-Z])/, '\1_\2'). tr("-", "_"). downcase end |