lib/atom/text.rb in atom-tools-0.9.4 vs lib/atom/text.rb in atom-tools-1.0.0

- old
+ new

@@ -103,20 +103,18 @@ if self["type"] == "text" e.attributes.delete "type" end # this should be done via inheritance - unless self.class == Atom::Content and self["src"] - c = convert_contents e + c = convert_contents e - if c.is_a? String - e.text = c - elsif c.is_a? REXML::Element - e << c.dup - else - raise RuntimeError, "atom:#{local_name} can't contain type #{@content.class}" - end + if c.is_a? String + e.text = c + elsif c.is_a? REXML::Element + e << c.dup + else + raise RuntimeError, "atom:#{local_name} can't contain type #{@content.class}" end e end @@ -172,9 +170,18 @@ if self["src"] "" else super end + end + + def to_element + if self["src"] + element_super = Element.instance_method(:to_element) + return element_super.bind(self).call + end + + super end private def valid_type? type super or type.match(/\//)