Class: Serializable::XBuilder
- Inherits:
-
Object
- Object
- Serializable::XBuilder
- Includes:
- ActionView::TemplateHandlers::Compilable
- Defined in:
- lib/serializable/xbuilder.rb
Instance Method Summary collapse
- #compile(template) ⇒ Object (also: #call)
Instance Method Details
#compile(template) ⇒ Object Also known as: call
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/serializable/xbuilder.rb', line 7 def compile(template) compiled_code = <<-CODE format = params[:format] if format && :json == format.to_sym _set_controller_content_type(Mime::JSON) xbuilder = ::Builder::HashStructure.new #{template.source} xbuilder.target!.to_json else _set_controller_content_type(Mime::XML) xbuilder = ::Builder::XmlMarkup.new #{template.source} xbuilder.target! end CODE compiled_code end |