diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2010-11-22 14:07:28 -0200 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2010-11-22 16:02:13 -0200 |
commit | 559c4292bcd132e87b50aa8f0807f2684cf234b8 (patch) | |
tree | 64e543f2826dc4d7ad7a890e41c74fdf2a94e602 /actionpack | |
parent | 115abd52b6bf6801dce7c3fbcb0e29d4213a5bb2 (diff) | |
download | rails-559c4292bcd132e87b50aa8f0807f2684cf234b8.tar.gz rails-559c4292bcd132e87b50aa8f0807f2684cf234b8.tar.bz2 rails-559c4292bcd132e87b50aa8f0807f2684cf234b8.zip |
Remove unneeded metaprogramming and method generation in favor of direct definition
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_controller/metal/renderers.rb | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/actionpack/lib/action_controller/metal/renderers.rb b/actionpack/lib/action_controller/metal/renderers.rb index f9b226b7c9..41bcae75c9 100644 --- a/actionpack/lib/action_controller/metal/renderers.rb +++ b/actionpack/lib/action_controller/metal/renderers.rb @@ -15,30 +15,12 @@ module ActionController end module ClassMethods - def _write_render_options - renderers = _renderers.map do |name, value| - <<-RUBY_EVAL - if options.key?(:#{name}) - _process_options(options) - return _render_option_#{name}(options.delete(:#{name}), options) - end - RUBY_EVAL - end - - class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1 - def _handle_render_options(options) - #{renderers.join} - end - RUBY_EVAL - end - def use_renderers(*args) new = _renderers.dup args.each do |key| new[key] = RENDERERS[key] end self._renderers = new.freeze - _write_render_options end alias use_renderer use_renderers end @@ -47,11 +29,20 @@ module ActionController _handle_render_options(options) || super end + def _handle_render_options(options) + _renderers.each do |name, value| + if options.key?(name.to_sym) + _process_options(options) + return send("_render_option_#{name}", options.delete(name.to_sym), options) + end + end + nil + end + RENDERERS = {} def self.add(key, &block) define_method("_render_option_#{key}", &block) RENDERERS[key] = block - All._write_render_options end module All @@ -61,13 +52,8 @@ module ActionController INCLUDED = [] included do self._renderers = RENDERERS - _write_render_options INCLUDED << self end - - def self._write_render_options - INCLUDED.each(&:_write_render_options) - end end add :json do |json, options| |