Module: Redmine::Views::Builders

Defined in:
lib/redmine/views/builders/json.rb,
lib/redmine/views/builders/structure.rb,
lib/redmine/views/builders/xml.rb,
lib/redmine/views/builders.rb

Overview

Since:

  • 1.1.0

Defined Under Namespace

Classes: Json, Structure, Xml

Class Method Summary collapse

Class Method Details

.for(format, request, response, &block) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/redmine/views/builders.rb', line 24

def self.for(format, request, response, &block)
  builder = case format
    when 'xml',  :xml;  Builders::Xml.new(request, response)
    when 'json', :json; Builders::Json.new(request, response)
    else; raise "No builder for format #{format}"
  end
  if block
    block.call(builder)
  else
    builder
  end
end