aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/object/inclusion.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/core_ext/object/inclusion.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/object/inclusion.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/object/inclusion.rb b/activesupport/lib/active_support/core_ext/object/inclusion.rb
index f30333fd02..51cfc62f2b 100644
--- a/activesupport/lib/active_support/core_ext/object/inclusion.rb
+++ b/activesupport/lib/active_support/core_ext/object/inclusion.rb
@@ -5,8 +5,11 @@ class Object
# characters = ["Konata", "Kagami", "Tsukasa"]
# "Konata".in?(characters) # => true
#
+ # This will throw an ArgumentError if the supplied argument doesnt not respond
+ # to +#include?+.
def in?(another_object)
- raise ArgumentError.new("You must supply another object that responds to include?") unless another_object.respond_to?(:include?)
another_object.include?(self)
+ rescue NoMethodError
+ raise ArgumentError.new("The parameter passed to #in? must respond to #include?")
end
end