Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/document_mapper/core_ext/object.rb
Overview
Backported from ActiveSupport 3.1. Should be removed once the 3.1 version is out.
Instance Method Summary collapse
-
#in?(another_object) ⇒ Boolean
Returns true if this object is included in the argument.
Instance Method Details
#in?(another_object) ⇒ Boolean
Returns true if this object is included in the argument. Argument must be 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?.
13 14 15 16 17 |
# File 'lib/document_mapper/core_ext/object.rb', line 13 def in?(another_object) another_object.include?(self) rescue NoMethodError raise ArgumentError.new("The parameter passed to #in? must respond to #include?") end |