diff options
author | Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com> | 2009-05-21 15:23:52 -0700 |
---|---|---|
committer | Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com> | 2009-05-21 15:23:52 -0700 |
commit | 9d3d7746702b65ddc09364c260ee4ace4b178281 (patch) | |
tree | a606692a746549ecc338e6bcb59de84722f3c2ff /actionpack/lib | |
parent | ad1c90de3a766d12a0906c7cf3772f3bc0e1b445 (diff) | |
download | rails-9d3d7746702b65ddc09364c260ee4ace4b178281.tar.gz rails-9d3d7746702b65ddc09364c260ee4ace4b178281.tar.bz2 rails-9d3d7746702b65ddc09364c260ee4ace4b178281.zip |
Update render options to remove performance implications of many render options types
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/new_base/render_options.rb | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/actionpack/lib/action_controller/new_base/render_options.rb b/actionpack/lib/action_controller/new_base/render_options.rb index a9ac0e0a41..aa6593b957 100644 --- a/actionpack/lib/action_controller/new_base/render_options.rb +++ b/actionpack/lib/action_controller/new_base/render_options.rb @@ -7,14 +7,32 @@ module ActionController self._renderers = [] end - def render_to_body(options) - _renderers.each do |renderer| - if options.key?(renderer) - _process_options(options) - return send("_render_#{renderer}", options[renderer], options) + module ClassMethods + def _write_render_options + renderers = _renderers.map do |r| + <<-RUBY_EVAL + if options.key?(:#{r}) + _process_options(options) + return _render_#{r}(options[:#{r}], options) + end + RUBY_EVAL end + + class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1 + def _handle_render_options(options) + #{renderers.join} + end + RUBY_EVAL + end + + def _add_render_option(name) + _renderers << name + _write_render_options end - super + end + + def render_to_body(options) + _handle_render_options(options) || super end end @@ -26,7 +44,7 @@ module ActionController depends_on RenderOptions def self.register_renderer(name) - included { _renderers << name } + included { _add_render_option(name) } end end end |