aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/core_ext/module/delegation.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/module/delegation.rb b/activesupport/lib/active_support/core_ext/module/delegation.rb
index e0b5f3e379..fee4454cb2 100644
--- a/activesupport/lib/active_support/core_ext/module/delegation.rb
+++ b/activesupport/lib/active_support/core_ext/module/delegation.rb
@@ -53,9 +53,11 @@ class Module
raise ArgumentError, "Delegation needs a target. Supply an options hash with a :to key as the last argument (e.g. delegate :hello, :to => :greeter)."
end
+ prefix = options[:prefix] ? "#{to}_" : ""
+
methods.each do |method|
module_eval(<<-EOS, "(__DELEGATION__)", 1)
- def #{method}(*args, &block)
+ def #{prefix}#{method}(*args, &block)
#{to}.__send__(#{method.inspect}, *args, &block)
end
EOS