Module: Diaspora::Parser

Included in:
PublicsController
Defined in:
lib/diaspora/parser.rb

Class Method Summary collapse

Class Method Details

.from_xml(xml) ⇒ Object


7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/diaspora/parser.rb', line 7

def self.from_xml(xml)
  doc = Nokogiri::XML(xml) { |cfg| cfg.noblanks }
  return unless body = doc.xpath("/XML/post").children.first
  class_name = body.name.gsub('-', '/')
  begin
    class_name.camelize.constantize.from_xml body.to_s
  rescue NameError => e
    # A pods is trying to federate an object we don't recognize.
    # i.e. their codebase is different from ours.  Quietly discard
    # so that no job failure is created
    nil
  end
end