1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Regenerate AV::Base subclass when DetailsKey gets cleared

This commit is contained in:
Aaron Patterson 2019-01-23 15:44:32 -08:00
parent f9bea6304d
commit 5b4df9d0eb
No known key found for this signature in database
GPG key ID: 953170BCB4FFAFC6
2 changed files with 29 additions and 3 deletions

View file

@ -186,8 +186,13 @@ module ActionView #:nodoc:
Class.new(self) {
include template_container
define_method(:compiled_method_container) { template_container }
define_singleton_method(:compiled_method_container) { template_container }
}
end
def changed?(other) # :nodoc:
compiled_method_container != other.compiled_method_container
end
end
attr_reader :view_renderer

View file

@ -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