diff options
author | Stan Lo <a22301613@yahoo.com.tw> | 2016-07-14 18:38:16 +0800 |
---|---|---|
committer | Stan Lo <a22301613@yahoo.com.tw> | 2016-08-08 00:24:39 +0800 |
commit | ab2af4dfcb61b568a9753b97dc55f1b45e3a824e (patch) | |
tree | 2e94a186941b1b890492828cefcaba1144b70836 /actionview/lib/action_view/renderer/partial_renderer.rb | |
parent | c4f8c45ba57e97e8dfc99f8bf6c2fbfd39abd58b (diff) | |
download | rails-ab2af4dfcb61b568a9753b97dc55f1b45e3a824e.tar.gz rails-ab2af4dfcb61b568a9753b97dc55f1b45e3a824e.tar.bz2 rails-ab2af4dfcb61b568a9753b97dc55f1b45e3a824e.zip |
Modify LogSubscriber for single partial's cache message.
Implement naive partial caching mechanism.
Add test for LogSubscriber
Use ActionView::Base#log_payload to store log_subscriber's payload, so we can pass cache result into it.
Fixed tests
Remove useless settings
Check if #log_payload exists before calling it. Because other classes also includes CacheHelper but don't have is attribute
Use @log_payload_for_partial_reder instead of #log_payload to carry ActionView's payload.
Update test's hash syntax
Add configuration to enable/disable fragment caching logging
Remove unless test and add new test to ensure cache info won't effect next rendering's log
Move :enable_fragment_cache_logging config from ActionView to ActionPack
Apply new config to tests
Update actionview's changelog
Update configuration guide
Improve actionview's changelog
Refactor PartialRenderer#render and log tests
Mute subscriber's log instead of disabling instrumentation.
Fix typo, remove useless comment and use new hash syntax
Improve actionpack's log_subscriber test
Fix rebase mistake
Apply new config to all caching intstrument actions
Diffstat (limited to 'actionview/lib/action_view/renderer/partial_renderer.rb')
-rw-r--r-- | actionview/lib/action_view/renderer/partial_renderer.rb | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/actionview/lib/action_view/renderer/partial_renderer.rb b/actionview/lib/action_view/renderer/partial_renderer.rb index 1509726a37..92bd0ccf91 100644 --- a/actionview/lib/action_view/renderer/partial_renderer.rb +++ b/actionview/lib/action_view/renderer/partial_renderer.rb @@ -308,9 +308,7 @@ module ActionView if @collection render_collection else - instrument(:partial) do - render_partial - end + render_partial end end @@ -331,22 +329,26 @@ module ActionView end def render_partial - view, locals, block = @view, @locals, @block - object, as = @object, @variable + instrument(:partial) do |payload| + view, locals, block = @view, @locals, @block + object, as = @object, @variable - if !block && (layout = @options[:layout]) - layout = find_template(layout.to_s, @template_keys) - end + view.instance_variable_set(:@log_payload_for_partial_render, payload) - object = locals[as] if object.nil? # Respect object when object is false - locals[as] = object if @has_object + if !block && (layout = @options[:layout]) + layout = find_template(layout.to_s, @template_keys) + end - content = @template.render(view, locals) do |*name| - view._layout_for(*name, &block) - end + object = locals[as] if object.nil? # Respect object when object is false + locals[as] = object if @has_object - content = layout.render(view, locals){ content } if layout - content + content = @template.render(view, locals) do |*name| + view._layout_for(*name, &block) + end + + content = layout.render(view, locals){ content } if layout + content + end end # Sets up instance variables needed for rendering a partial. This method |