diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2016-04-20 23:58:22 -0300 |
---|---|---|
committer | Rafael França <rafaelmfranca@gmail.com> | 2016-04-20 23:58:22 -0300 |
commit | 7c0b9624d08d3fc112f8f928c9553276025b0401 (patch) | |
tree | 5344eca15a7f308aec9cf6e9dfded4a751203c2f | |
parent | 218d23622b5fc3d899312ebe45837009661aca07 (diff) | |
parent | 406047d3acf94e3ce15705f870881632f631c52d (diff) | |
download | rails-7c0b9624d08d3fc112f8f928c9553276025b0401.tar.gz rails-7c0b9624d08d3fc112f8f928c9553276025b0401.tar.bz2 rails-7c0b9624d08d3fc112f8f928c9553276025b0401.zip |
Merge pull request #24666 from tlynam/patch-1
Update delegate to use newer Ruby syntax
-rw-r--r-- | activesupport/lib/active_support/core_ext/module/delegation.rb | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/activesupport/lib/active_support/core_ext/module/delegation.rb b/activesupport/lib/active_support/core_ext/module/delegation.rb index 0d46248582..24450cd221 100644 --- a/activesupport/lib/active_support/core_ext/module/delegation.rb +++ b/activesupport/lib/active_support/core_ext/module/delegation.rb @@ -149,14 +149,11 @@ class Module # # The target method must be public, otherwise it will raise +NoMethodError+. # - def delegate(*methods) - options = methods.pop - unless options.is_a?(Hash) && to = options[:to] + def delegate(*methods, to: nil, prefix: nil, allow_nil: nil) + unless to 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, allow_nil = options.values_at(:prefix, :allow_nil) - if prefix == true && to =~ /^[^a-z_]/ raise ArgumentError, 'Can only automatically set the delegation prefix when delegating to a method.' end |