private Method

XmlSimple.collapse_text_node(hash, element)

Collapses a text node and merges it with an existing Hash, if possible. Thanks to Curtis Schofield for reporting a subtle bug.

hash:Hash to merge text node value with, if possible.
element:Text node to be collapsed.

Source Code

# File active_support/vendor/xml-simple-1.0.11/xmlsimple.rb, line 523
def collapse_text_node(hash, element)
  value = node_to_text(element)
  if empty(value) && !element.has_attributes?
    return {}
  end

  if element.has_attributes? && !@options['noattr']
    return merge(hash, @options['contentkey'], value)
  else
    if @options['forcecontent']
      return merge(hash, @options['contentkey'], value)
    else
      return value
    end
  end
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.