diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2019-01-23 15:44:32 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2019-02-06 16:57:00 -0800 |
commit | 5b4df9d0eb295d402489465f3600576038f5762d (patch) | |
tree | b3272f83a9833494e327b057fc38073202f722b0 /actionview/lib/action_view/rendering.rb | |
parent | f9bea6304dfba902b1937b3bc29b1ebc2f67e55b (diff) | |
download | rails-5b4df9d0eb295d402489465f3600576038f5762d.tar.gz rails-5b4df9d0eb295d402489465f3600576038f5762d.tar.bz2 rails-5b4df9d0eb295d402489465f3600576038f5762d.zip |
Regenerate AV::Base subclass when DetailsKey gets cleared
Diffstat (limited to 'actionview/lib/action_view/rendering.rb')
-rw-r--r-- | actionview/lib/action_view/rendering.rb | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/actionview/lib/action_view/rendering.rb b/actionview/lib/action_view/rendering.rb index 01caa82ec6..8246e4ba6d 100644 --- a/actionview/lib/action_view/rendering.rb +++ b/actionview/lib/action_view/rendering.rb @@ -35,14 +35,35 @@ module ActionView end module ClassMethods + def _routes + end + + def _helpers + end + + def build_av_class(klass, supports_path, routes, helpers) + Class.new(klass) do + if routes + include routes.url_helpers(supports_path) + include routes.mounted_helpers + end + + if helpers + include helpers + end + end + end + def view_context_class klass = ActionView::LookupContext::DetailsKey.view_context_class(ActionView::Base) - @view_context_class ||= build_view_context_class(klass, supports_path?, _routes, _helpers) + @view_context_class ||= build_av_class(klass, supports_path?, _routes, _helpers) if klass.changed?(@view_context_class) - @view_context_class = build_view_context_class(klass, supports_path?, _routes, _helpers) + @view_context_class = build_av_class(klass, supports_path?, _routes, _helpers) end + + @view_context_class end end |