aboutsummaryrefslogblamecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/object/exclusion.rb
blob: 58dfb649e5a4896694793accac5bbc4a02e045f2 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15














                                                                                         
class Object
  # Returns true if this object is excluded in the argument. Argument must be
  # any object which responds to +#include?+. Usage:
  #
  #   characters = ["Konata", "Kagami", "Tsukasa"]
  #   "MoshiMoshi".not_in?(characters) # => true
  #
  # This will throw an +ArgumentError+ if the argument doesn't respond
  # to +#include?+.
  def not_in?(another_object)
    !another_object.include?(self)
  rescue NoMethodError
    raise ArgumentError.new("The parameter passed to #not_in? must respond to #include?")
  end
end