Skip to content
Newer
Older
100644 76 lines (61 sloc) 2 KB
aed135d @josevalim Renamed presenter to renderer, added some documentation and defined i…
josevalim authored Aug 6, 2009
1 module ActionController
83f4d86 @dhh Rename the RenderingController module to just plain Rendering
dhh authored Dec 20, 2009
2 module Rendering
aed135d @josevalim Renamed presenter to renderer, added some documentation and defined i…
josevalim authored Aug 6, 2009
3 extend ActiveSupport::Concern
4
f2c0a35 @josevalim Finish cleaning up rendering stack from views and move assigns evalua…
josevalim authored Mar 12, 2010
5 # Before processing, set the request formats in current controller formats.
4ba334c @josevalim Ensure controller filters are executed before stuff starts to happen.
josevalim authored Mar 13, 2010
6 def process_action(*) #:nodoc:
24b1d4f @pixeltrix Return nil for Mime::NullType#ref
pixeltrix authored Apr 10, 2013
7 self.formats = request.formats.map(&:ref).compact
aed135d @josevalim Renamed presenter to renderer, added some documentation and defined i…
josevalim authored Aug 6, 2009
8 super
9 end
10
f2c0a35 @josevalim Finish cleaning up rendering stack from views and move assigns evalua…
josevalim authored Mar 12, 2010
11 # Check for double render errors and set the content_type after rendering.
12 def render(*args) #:nodoc:
7d81004 @lukaszx0 Add #rendered_format method to controllers
lukaszx0 authored Aug 2, 2013
13 raise ::AbstractController::DoubleRenderError if self.response_body
34b2180 @josevalim More refactoring. Split _normalize_args and _normalize_options concerns.
josevalim authored Mar 8, 2010
14 super
15 end
16
a66c917 @josevalim Do not inherit from Rack::Response, remove a shit-ton of unused code.
josevalim authored Apr 19, 2011
17 # Overwrite render_to_string because body can now be set to a rack body.
18 def render_to_string(*)
c27fde2 @spastorino render_to_string shouldn't play with response_body
spastorino authored Sep 4, 2013
19 result = super
20 if result.respond_to?(:each)
a66c917 @josevalim Do not inherit from Rack::Response, remove a shit-ton of unused code.
josevalim authored Apr 19, 2011
21 string = ""
c27fde2 @spastorino render_to_string shouldn't play with response_body
spastorino authored Sep 4, 2013
22 result.each { |r| string << r }
a66c917 @josevalim Do not inherit from Rack::Response, remove a shit-ton of unused code.
josevalim authored Apr 19, 2011
23 string
c27fde2 @spastorino render_to_string shouldn't play with response_body
spastorino authored Sep 4, 2013
24 else
25 result
a66c917 @josevalim Do not inherit from Rack::Response, remove a shit-ton of unused code.
josevalim authored Apr 19, 2011
26 end
27 end
28
a416695 @josevalim Remove BasicRendering and remove template functionality from AbsC::Re…
josevalim authored Sep 9, 2013
29 def render_to_body(options = {})
1529e61 @akshay-vishnoi #presence used
akshay-vishnoi authored Nov 14, 2013
30 super || options[:text].presence || ' '
67c96ab @carlosantoniodasilva Move render_to_body logic to return a spaced string to AC::Rendering
carlosantoniodasilva authored Jan 15, 2012
31 end
32
aed135d @josevalim Renamed presenter to renderer, added some documentation and defined i…
josevalim authored Aug 6, 2009
33 private
0396004 @josevalim Add some basic render_test to AbstractController.
josevalim authored Oct 21, 2009
34
67336ce @josevalim Remove remaining coupling with AV in MimeResponds
josevalim authored Sep 9, 2013
35 def _process_format(format)
36 super
37 self.content_type ||= format.to_s
38 end
39
4f3b5b8 @spastorino Fix indentation
spastorino authored Nov 20, 2010
40 # Normalize arguments by catching blocks and setting them on :update.
41 def _normalize_args(action=nil, options={}, &blk) #:nodoc:
42 options = super
43 options[:update] = blk if block_given?
44 options
45 end
a39c750 @josevalim Cleanup render callstack and make render(:json => {}, :status => 401)…
josevalim authored Feb 24, 2010
46
4f3b5b8 @spastorino Fix indentation
spastorino authored Nov 20, 2010
47 # Normalize both text and status options.
48 def _normalize_options(options) #:nodoc:
49 if options.key?(:text) && options[:text].respond_to?(:to_text)
50 options[:text] = options[:text].to_text
51 end
d618b7e @josevalim Ensure strings given to render with slash are rendered relative to th…
josevalim authored Jan 22, 2010
52
53596d0 @carlosantoniodasilva Refactor render nothing/text => nil logic, and move to right place
carlosantoniodasilva authored Jan 15, 2012
53 if options.delete(:nothing) || (options.key?(:text) && options[:text].nil?)
54 options[:text] = " "
55 end
56
4f3b5b8 @spastorino Fix indentation
spastorino authored Nov 20, 2010
57 if options[:status]
58 options[:status] = Rack::Utils.status_code(options[:status])
d618b7e @josevalim Ensure strings given to render with slash are rendered relative to th…
josevalim authored Jan 22, 2010
59 end
a39c750 @josevalim Cleanup render callstack and make render(:json => {}, :status => 401)…
josevalim authored Feb 24, 2010
60
4f3b5b8 @spastorino Fix indentation
spastorino authored Nov 20, 2010
61 super
62 end
0a85380 @josevalim Finally moved the find template logic to the views.
josevalim authored Mar 8, 2010
63
4f3b5b8 @spastorino Fix indentation
spastorino authored Nov 20, 2010
64 # Process controller specific options, as status, content-type and location.
65 def _process_options(options) #:nodoc:
66 status, content_type, location = options.values_at(:status, :content_type, :location)
0a85380 @josevalim Finally moved the find template logic to the views.
josevalim authored Mar 8, 2010
67
4f3b5b8 @spastorino Fix indentation
spastorino authored Nov 20, 2010
68 self.status = status if status
69 self.content_type = content_type if content_type
70 self.headers["Location"] = url_for(location) if location
0a85380 @josevalim Finally moved the find template logic to the views.
josevalim authored Mar 8, 2010
71
4f3b5b8 @spastorino Fix indentation
spastorino authored Nov 20, 2010
72 super
73 end
aed135d @josevalim Renamed presenter to renderer, added some documentation and defined i…
josevalim authored Aug 6, 2009
74 end
75 end
Something went wrong with that request. Please try again.