Class: Medie::Xml::Driver
- Inherits:
-
Object
- Object
- Medie::Xml::Driver
- Defined in:
- lib/medie/xml/driver.rb
Instance Method Summary collapse
- #can_handle?(content_type) ⇒ Boolean
- #marshal(obj, options = {}) ⇒ Object
- #unmarshal(content) ⇒ Object
Instance Method Details
#can_handle?(content_type) ⇒ Boolean
27 28 29 30 31 32 |
# File 'lib/medie/xml/driver.rb', line 27 def can_handle?(content_type) !(content_type.nil? || (content_type.split(";")[0]!="application/xml" && content_type.split(";")[0]!="application/atom+xml" && content_type.split(";")[0]!="text/xml")) end |
#marshal(obj, options = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/medie/xml/driver.rb', line 4 def marshal(obj, = {}) if(obj.kind_of?(String)) obj elsif obj.kind_of?(Hash) && obj.size==1 root = obj.values.first if !root.respond_to?(:to_xml) raise "Trying to marshal a string into xml does not make sense: '#{obj}'" end root.to_xml(:root => obj.keys.first) else obj.to_xml end end |