Method: HappyMapper::ClassMethods#content

Defined in:
lib/happymapper.rb

#content(name, type, options = {}) ⇒ Object

The value stored in the text node of the current element.

Examples:


"<firstName>Michael Jackson</firstName>"

# definition of the 'firstName' text node within the class

content :first_name, String

Parameters:

  • name (Symbol)

    the name of the accessor that is created

  • type (String, Class)

    the class name of the name of the class whcih the object will be converted upon parsing

  • options (Hash) (defaults to: {})

    additional parameters to send to the relationship



127
128
129
130
# File 'lib/happymapper.rb', line 127

def content(name, type, options={})
  @content = TextNode.new(name, type, options)
  attr_accessor @content.method_name.intern
end