class Medie::Xml::Driver

Public Instance Methods

can_handle?(content_type) click to toggle source
# 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 = {}) click to toggle source
# File lib/medie/xml/driver.rb, line 4
def marshal(obj, options = {})
  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
unmarshal(content) click to toggle source
# File lib/medie/xml/driver.rb, line 18
def unmarshal(content)
  if content
    hash = Hash.from_xml(content)
  else
    hash = {}
  end
  hash.extend(Methodize).extend(Medie::Linked).use_link_type(Medie::Xml::Links)
end