From e1029be1ebe0e44cdad75dc9b1bdfd3957c245bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Mon, 18 Jan 2010 23:32:01 +0100 Subject: [PATCH] Since Rails will require Ruby >= 1.8.7, we can rely on instance_exec. --- .../lib/generators/rails/plugin/plugin_generator.rb | 12 ++++++------ .../lib/rails/vendor/thor-0.12.3/lib/thor/group.rb | 9 ++++++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/railties/lib/generators/rails/plugin/plugin_generator.rb b/railties/lib/generators/rails/plugin/plugin_generator.rb index ee785caf7d..b68b8691db 100644 --- a/railties/lib/generators/rails/plugin/plugin_generator.rb +++ b/railties/lib/generators/rails/plugin/plugin_generator.rb @@ -20,15 +20,15 @@ module Rails directory 'tasks', plugin_dir('tasks') end - hook_for :generator do |instance, generator| - instance.inside instance.send(:plugin_dir), :verbose => true do - instance.invoke generator, [ instance.name ], :namespace => false + hook_for :generator do |generator| + inside plugin_dir, :verbose => true do + invoke generator, [ name ], :namespace => false end end - hook_for :test_framework do |instance, test_framework| - instance.inside instance.send(:plugin_dir), :verbose => true do - instance.invoke test_framework + hook_for :test_framework do |test_framework| + inside plugin_dir, :verbose => true do + invoke test_framework end end diff --git a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/group.rb b/railties/lib/rails/vendor/thor-0.12.3/lib/thor/group.rb index a585b37b73..eda3b52c4f 100644 --- a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/group.rb +++ b/railties/lib/rails/vendor/thor-0.12.3/lib/thor/group.rb @@ -252,10 +252,13 @@ class Thor::Group shell.padding += 1 result = if block_given? - if block.arity == 2 - block.call(self, klass) - else + case block.arity + when 3 block.call(self, klass, task) + when 2 + block.call(self, klass) + when 1 + instance_exec(klass, &block) end else invoke klass, task, *args