instance method
presence_in
Ruby on Rails 4.1.16
Since v4.1.16Signature
presence_in(another_object)
Returns the receiver if it’s included in the argument otherwise returns nil. Argument must be any object which responds to #include?. Usage:
params[:bucket_type].presence_in %w( project calendar )
This will throw an ArgumentError if the argument doesn’t respond to #include?.
@return [Object]
Parameters
-
another_objectreq
Source
# File activesupport/lib/active_support/core_ext/object/inclusion.rb, line 24
def presence_in(another_object)
self.in?(another_object) ? self : nil
end
Defined in activesupport/lib/active_support/core_ext/object/inclusion.rb line 24
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Object