module WorldpayCnp::XML::Serializer
Public Instance Methods
call(hash)
click to toggle source
# File lib/worldpay_cnp/xml/serializer.rb, line 4 def call(hash) raise NotImplementedError end
Private Instance Methods
add_xml_elements!(parent, obj)
click to toggle source
# File lib/worldpay_cnp/xml/serializer.rb, line 18 def add_xml_elements!(parent, obj) case obj when Hash obj.each { |key, value| attributes_or_elements!(parent, key, value) } when Array obj.each { |value| add_xml_elements!(parent, value) } else insert_text!(parent, obj) end parent end
attribute?(key)
click to toggle source
# File lib/worldpay_cnp/xml/serializer.rb, line 34 def attribute?(key) key.to_s.start_with?("@") end
attribute_name(key)
click to toggle source
# File lib/worldpay_cnp/xml/serializer.rb, line 38 def attribute_name(key) key.to_s.sub(/^@/, "") end
attributes_or_elements!(parent, key, value)
click to toggle source
# File lib/worldpay_cnp/xml/serializer.rb, line 10 def attributes_or_elements!(parent, key, value) raise NotImplementedError end
insert_text!(element, text)
click to toggle source
# File lib/worldpay_cnp/xml/serializer.rb, line 14 def insert_text!(element, text) raise NotImplementedError end
text_with(obj)
click to toggle source
# File lib/worldpay_cnp/xml/serializer.rb, line 30 def text_with(obj) obj.to_s end