From fd205edd7dacc832dd6298531702dbea00aba8dd Mon Sep 17 00:00:00 2001 From: okuramasafumi Date: Mon, 29 Apr 2019 11:32:49 +0900 Subject: Improve error message of ActiveSupport delegate ActiveSupport `delegate` has `to` option, but it's not a option hash anymore and now it's a keyword argument. When `to` argument is not given, it raises an ArgumentError but the message suggests supplying "options hash", which is now wrong. Now it's fixed to provide correct suggestion to supply a keyword argument. --- activesupport/lib/active_support/core_ext/module/delegation.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport/lib/active_support/core_ext/module') diff --git a/activesupport/lib/active_support/core_ext/module/delegation.rb b/activesupport/lib/active_support/core_ext/module/delegation.rb index 5652f2d1cc..9fe7f8fe01 100644 --- a/activesupport/lib/active_support/core_ext/module/delegation.rb +++ b/activesupport/lib/active_support/core_ext/module/delegation.rb @@ -170,7 +170,7 @@ class Module # The target method must be public, otherwise it will raise +NoMethodError+. def delegate(*methods, to: nil, prefix: nil, allow_nil: nil, private: 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)." + raise ArgumentError, "Delegation needs a target. Supply a keyword argument 'to' (e.g. delegate :hello, to: :greeter)." end if prefix == true && /^[^a-z_]/.match?(to) -- cgit v1.2.3