diff options
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/core_ext/module/delegation.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/module/delegation.rb b/activesupport/lib/active_support/core_ext/module/delegation.rb index 1ad18402e5..2905eebc85 100644 --- a/activesupport/lib/active_support/core_ext/module/delegation.rb +++ b/activesupport/lib/active_support/core_ext/module/delegation.rb @@ -78,6 +78,10 @@ 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 + if options[:prefix] == true && options[:to].to_s =~ /^[^a-z_]/ + raise ArgumentError, "Can only automatically set the delegation prefix when delegating to a method." + end + prefix = options[:prefix] && "#{options[:prefix] == true ? to : options[:prefix]}_" methods.each do |method| |