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













                                                                             
                                                              
   
                      


                          
class Object
  # Returns true if this object is included in the argument. Argument must be
  # any object which respond to +#include?+. Usage:
  #
  #   characters = ["Konata", "Kagami", "Tsukasa"]
  #   "Konata".in?(characters) # => true
  #
  def in?(another_object)
    another_object.include?(self)
  end

  # Returns true if this object is included in the argument list. Usage:
  #
  #   username = "sikachu"
  #   username.among?("josevalim", "dhh", "wycats") # => false
  #
  def among?(*objects)
    objects.include?(self)
  end
end