Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #10828 from southpolesteve/delegation_error_class

Create DelegationError class
  • Loading branch information...
commit 3f50dd21c13359735bb40c5693010c6dd5e4b132 2 parents 577fad1 + 8139d72
@senny senny authored
View
4 activesupport/lib/active_support/core_ext/module/delegation.rb
@@ -176,7 +176,7 @@ def #{method_prefix}#{method}(#{definition}) # def customer_name(*args, &
end # end
EOS
else
- exception = %(raise "#{self}##{method_prefix}#{method} delegated to #{to}.#{method}, but #{to} is nil: \#{self.inspect}")
+ exception = %(raise DelegationError, "#{self}##{method_prefix}#{method} delegated to #{to}.#{method}, but #{to} is nil: \#{self.inspect}")
module_eval(<<-EOS, file, line - 2)
def #{method_prefix}#{method}(#{definition}) # def customer_name(*args, &block)
@@ -194,3 +194,5 @@ def #{method_prefix}#{method}(#{definition}) # def customer_name(*args, &
end
end
end
+
+class DelegationError < StandardError ; end
View
2  activesupport/test/core_ext/module_test.rb
@@ -207,7 +207,7 @@ def test_delegation_with_allow_nil_and_nil_value_and_prefix
def test_delegation_without_allow_nil_and_nil_value
david = Someone.new("David")
- assert_raise(RuntimeError) { david.street }
+ assert_raise(DelegationError) { david.street }
end
def test_delegation_to_method_that_exists_on_nil
Please sign in to comment.
Something went wrong with that request. Please try again.