lib/xommelier/xml/element/serialization.rb in xommelier-0.1.15 vs lib/xommelier/xml/element/serialization.rb in xommelier-0.1.16

- old
+ new

@@ -46,12 +46,12 @@ xml = Nokogiri::XML(xml) end @_xml_node = options.delete(:node) { xml.at_xpath(element_xpath(xml.document, element_name)) } validate if options[:validate] - if text? && @_xml_node.text? - self.text = @_xml_node.text + if text? && @_xml_node.inner_html.present? + self.text = @_xml_node.inner_html end self.class.attributes.each do |name, options| deserialize_attribute(name, options) end @@ -127,9 +127,41 @@ else value = value.first end hash[name] = value end + end + end + + def <=>(other) + if text? && other.is_a?(String) + text.to_s <=> other + else + super + end + end + + def ==(other) + if text? && other.is_a?(String) + text.to_s == other + else + super + end + end + + def =~(other) + if text? && other.is_a?(Regexp) + text.to_s =~ other + else + super + end + end + + def to_s + if text? + text.to_s + else + super end end protected