Regenerate AV::Base subclass when DetailsKey gets cleared

上级 f9bea630
......@@ -185,9 +185,14 @@ def with_empty_template_cache # :nodoc:
template_container = Module.new
Class.new(self) {
include template_container
define_method(:compiled_method_container) { 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
......
......@@ -35,14 +35,35 @@ def process(*) #:nodoc:
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册