diff options
Diffstat (limited to 'activesupport/lib/active_support/core_ext/object/inclusion.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/object/inclusion.rb | 6 |
1 files changed, 5 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 cc7edc0f17..b5671f66d0 100644 --- a/activesupport/lib/active_support/core_ext/object/inclusion.rb +++ b/activesupport/lib/active_support/core_ext/object/inclusion.rb @@ -1,11 +1,15 @@ class Object # Returns true if this object is included in the argument. Argument must be - # any object which respond to +#include?+. Usage: + # any object which responds to +#include?+. Usage: # # characters = ["Konata", "Kagami", "Tsukasa"] # "Konata".in?(characters) # => true # + # This will throw an ArgumentError if the argument doesn't respond + # to +#include?+. def in?(another_object) another_object.include?(self) + rescue NoMethodError + raise ArgumentError.new("The parameter passed to #in? must respond to #include?") end end |