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
41
42
|
# 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
Rails.logger.error "No builder for format #{format.inspect}"
response.status = 406
return "We couldn't handle your request, sorry. If you were trying to access the API, make sure to append .json or .xml to your request URL.\n"
end
if block_given?
yield(builder)
else
builder
end
end
|