Method: Object#presence_in
- Defined in:
- lib/active_support/core_ext/object/inclusion.rb
permalink #presence_in(another_object) ⇒ 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?
.
34 35 36 |
# File 'lib/active_support/core_ext/object/inclusion.rb', line 34 def presence_in(another_object) in?(another_object) ? self : nil end |