aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/array_inquirer.rb
Commit message (Collapse)AuthorAgeFilesLines
* Add ActiveSupport::ArrayInquirer and Array#inquiryGeorge Claghorn2015-03-241-0/+38
Wrapping an array in an `ArrayInquirer` gives a friendlier way to check its string-like contents. For example, `request.variant` returns an `ArrayInquirer` object. To check a request's variants, you can call: request.variant.phone? request.variant.any?(:phone, :tablet) ...instead of: request.variant.include?(:phone) request.variant.any? { |v| v.in?([:phone, :tablet]) } `Array#inquiry` is a shortcut for wrapping the receiving array in an `ArrayInquirer`: pets = [:cat, :dog] pets.cat? # => true pets.ferret? # => false pets.any?(:cat, :ferret} # => true