Module: Ext::XmlView::Base

Defined in:
lib/ext/xml_view.rb

Instance Method Summary collapse

Instance Method Details

#xml_view(m, *a) {|xml| ... } ⇒ Object

For controllers which pass back XML directly, this method allows quick assignment of the status code and takes care of generating the XML headers. Takes a block which receives the Builder::XmlMarkup object.

Yields:

  • (xml)


36
37
38
39
40
41
42
43
# File 'lib/ext/xml_view.rb', line 36

def xml_view(m, *a, &b)
  xml = Builder::XmlMarkup.new
  xml.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8"
  yield xml
  @headers['Content-Type'] = 'application/xml'
  @headers['Encoding']     = 'UTF-8'
  xml.target!
end