aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2008-08-26 12:14:21 -0500
committerJoshua Peek <josh@joshpeek.com>2008-08-26 12:17:55 -0500
commit229eedfda87a7706dbb5e3e51af8707b3adae375 (patch)
tree1a782151632dd80c8a18c3960536bdf8643debe3 /actionpack/lib/action_view
parentc111522d5b8cd108756240a0348d515d6acee46c (diff)
downloadrails-229eedfda87a7706dbb5e3e51af8707b3adae375.tar.gz
rails-229eedfda87a7706dbb5e3e51af8707b3adae375.tar.bz2
rails-229eedfda87a7706dbb5e3e51af8707b3adae375.zip
Cache JavaScriptGenerator's helper module set on the template
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r--actionpack/lib/action_view/base.rb5
-rw-r--r--actionpack/lib/action_view/helpers/prototype_helper.rb22
2 files changed, 20 insertions, 7 deletions
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb
index e1f35b8105..d174c784f3 100644
--- a/actionpack/lib/action_view/base.rb
+++ b/actionpack/lib/action_view/base.rb
@@ -328,11 +328,6 @@ module ActionView #:nodoc:
memoize :pick_template
private
- def extended_by_without_helpers #:nodoc:
- extended_by.reject { |mod| mod.name =~ /^ActionView::Helpers/ }
- end
- memoize :extended_by_without_helpers
-
# Evaluate the local assigns and pushes them to the view.
def evaluate_assigns
unless @assigns_added
diff --git a/actionpack/lib/action_view/helpers/prototype_helper.rb b/actionpack/lib/action_view/helpers/prototype_helper.rb
index 09dbb67c0a..ff83494e94 100644
--- a/actionpack/lib/action_view/helpers/prototype_helper.rb
+++ b/actionpack/lib/action_view/helpers/prototype_helper.rb
@@ -588,8 +588,26 @@ module ActionView
private
def include_helpers_from_context
- @context.send(:extended_by_without_helpers).each { |mod| extend mod }
- extend GeneratorMethods
+ unless generator_methods_module = @context.instance_variable_get(:@__javascript_generator_methods__)
+ modules = @context.extended_by - ([ActionView::Helpers] + ActionView::Helpers.included_modules)
+
+ generator_methods_module = Module.new do
+ modules.each do |mod|
+ begin
+ include mod
+ rescue Exception => e
+ # HACK: Probably not a good idea to suppress these warnings
+ # AFAIK exceptions are only raised in while testing with mocha
+ # because the module does not like to be included into other
+ # non TestUnit classes
+ end
+ end
+ include GeneratorMethods
+ end
+ @context.instance_variable_set(:@__javascript_generator_methods__, generator_methods_module)
+ end
+
+ extend generator_methods_module
end
# JavaScriptGenerator generates blocks of JavaScript code that allow you