Flowdock
to_xml(options={}) public

Converts the resource to an XML string representation.

Options

The options parameter is handed off to the to_xml method on each attribute, so it has the same options as the to_xml methods in Active Support.

  • :indent - Set the indent level for the XML output (default is 2).
  • :dasherize - Boolean option to determine whether or not element names should replace underscores with dashes. Default is true. The default can be set to false by setting the module attribute ActiveSupport.dasherize_xml = false in an initializer. Because save uses this method, and there are no options on save, then you will have to set the default if you don’t want underscores in element names to become dashes when the resource is saved. This is important when integrating with non-Rails applications.
  • :camelize - Boolean option to determine whether or not element names should be converted to camel case, e.g some_name to SomeName. Default is false. Like :dasherize you can change the default by setting the module attribute ActiveSupport.camelise_xml = true in an initializer.
  • :skip_instruct - Toggle skipping the instruct! call on the XML builder that generates the XML declaration (default is false).

Examples

  my_group = SubsidiaryGroup.find(:first)
  my_group.to_xml
  # => <?xml version="1.0" encoding="UTF-8"?>
  #    <subsidiary_group> [...] </subsidiary_group>

  my_group.to_xml(:dasherize => true)
  # => <?xml version="1.0" encoding="UTF-8"?>
  #    <subsidiary-group> [...] </subsidiary-group>

  my_group.to_xml(:skip_instruct => true)
  # => <subsidiary_group> [...] </subsidiary_group>
Show source
Register or log in to add new notes.