diff --git a/lib/multi_xml.rb b/lib/multi_xml.rb index 114e050..80526ce 100644 --- a/lib/multi_xml.rb +++ b/lib/multi_xml.rb @@ -176,7 +176,7 @@ def typecast_xml_value(value) when Hash if value['type'] == 'array' _, entries = wrap(value.detect{|key, value| key != 'type'}) - if entries.nil? || entries.strip.empty? || (c = value[CONTENT_ROOT] && c.blank?) + if entries.blank? || (c = value[CONTENT_ROOT] && c.blank?) [] else case entries diff --git a/lib/multi_xml/core_extensions.rb b/lib/multi_xml/core_extensions.rb index e4f02a7..423a614 100644 --- a/lib/multi_xml/core_extensions.rb +++ b/lib/multi_xml/core_extensions.rb @@ -8,7 +8,7 @@ class Object #:nodoc: # Returns true if the object is nil or empty (if applicable) def blank? nil? || (respond_to?(:empty?) && empty?) - end unless method_defined?(:blank?) + end end class Numeric #:nodoc: @@ -17,7 +17,7 @@ class Numeric #:nodoc: # Numerics can't be blank def blank? false - end unless method_defined?(:blank?) + end end class NilClass #:nodoc: @@ -26,7 +26,7 @@ class NilClass #:nodoc: # Nils are always blank def blank? true - end unless method_defined?(:blank?) + end end class TrueClass #:nodoc: @@ -35,14 +35,14 @@ class TrueClass #:nodoc: # True is not blank. def blank? false - end unless method_defined?(:blank?) + end end class FalseClass #:nodoc: # False is always blank. def blank? true - end unless method_defined?(:blank?) + end end class String #:nodoc: @@ -55,5 +55,5 @@ class String #:nodoc: # Strips out whitespace then tests if the string is empty. def blank? strip.empty? - end unless method_defined?(:blank?) + end end diff --git a/lib/multi_xml/parsers/rexml.rb b/lib/multi_xml/parsers/rexml.rb index 2272c60..7a801ae 100644 --- a/lib/multi_xml/parsers/rexml.rb +++ b/lib/multi_xml/parsers/rexml.rb @@ -23,12 +23,10 @@ def parse(xml) else xml.ungetc(char) doc = REXML::Document.new(xml) - if doc.root merge_element!({}, doc.root) else - raise REXML::ParseException, - "The document #{doc.to_s.inspect} does not have a valid root" + raise REXML::ParseException, "The document #{doc.to_s.inspect} does not have a valid root" end end end diff --git a/spec/multi_xml_spec.rb b/spec/multi_xml_spec.rb index 3c64edd..36c3b73 100644 --- a/spec/multi_xml_spec.rb +++ b/spec/multi_xml_spec.rb @@ -461,7 +461,6 @@ def self.parse(xml) end it "should parse correctly" do - pending MultiXml.parse(@xml).should == {"user"=>{"name"=>"Erik Michaels-Ober"}} end end