Module: Redmine::Views::Builders

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

Defined Under Namespace

Classes: Json, Structure, Xml

Class Method Summary collapse

Class Method Details

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


27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/redmine/views/builders.rb', line 27

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