instance method
presence_in
Ruby on Rails edge
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:
```ruby
params[:bucket_type].presence_in %w( project calendar )
```
This will throw an `ArgumentError` if the argument doesn't respond to `#include?`.
@return [Object]
: (untyped) -> self?
Parameters
-
another_objectreq
Source
# File activesupport/lib/active_support/core_ext/object/inclusion.rb, line 40
def presence_in(another_object)
in?(another_object) ? self : nil
end
Defined in activesupport/lib/active_support/core_ext/object/inclusion.rb line 40
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Object