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:
parent
f9bea6304d
commit
5b4df9d0eb
2 changed files with 29 additions and 3 deletions
|
@ -185,9 +185,14 @@ module ActionView #:nodoc:
|
||||||
template_container = Module.new
|
template_container = Module.new
|
||||||
Class.new(self) {
|
Class.new(self) {
|
||||||
include template_container
|
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
|
end
|
||||||
|
|
||||||
|
def changed?(other) # :nodoc:
|
||||||
|
compiled_method_container != other.compiled_method_container
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_reader :view_renderer
|
attr_reader :view_renderer
|
||||||
|
|
|
@ -35,14 +35,35 @@ module ActionView
|
||||||
end
|
end
|
||||||
|
|
||||||
module ClassMethods
|
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
|
def view_context_class
|
||||||
klass = ActionView::LookupContext::DetailsKey.view_context_class(ActionView::Base)
|
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)
|
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
|
end
|
||||||
|
|
||||||
|
@view_context_class
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue