Permalink
Browse files

* lib/facebooker/parser.rb: only requiring rexml if we really need it

  • Loading branch information...
1 parent bc3b2a4 commit 73fa2694a7b47746577ef132e1f84f2becb6edbd @tenderlove tenderlove committed May 14, 2010
Showing with 6 additions and 4 deletions.
  1. +6 −4 lib/facebooker/parser.rb
@@ -1,9 +1,9 @@
-require 'rexml/document'
require 'facebooker/session'
begin
- require 'nokogiri'
+ require 'nokogiri'
rescue Exception
+ require 'rexml/document'
end
module Facebooker
@@ -29,8 +29,10 @@ def text?
end
end
- ::REXML::Element.__send__(:include, REXMLElementExtensions)
- ::REXML::Text.__send__(:include, REXMLTextExtensions)
+ if Object.const_defined?(:REXML) && REXML.const_defined?(:Element)
+ ::REXML::Element.__send__(:include, REXMLElementExtensions)
+ ::REXML::Text.__send__(:include, REXMLTextExtensions)
+ end
def self.parse(method, data)
Errors.process(data)

0 comments on commit 73fa269

Please sign in to comment.