1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
Commit graph

4 commits

Author SHA1 Message Date
Rafael Mendonça França
f9433ef260 Require the extensions to tests pass in isolation 2015-03-30 13:59:50 -03:00
Rafael Mendonça França
b5c35023bd Revert "Remove Array#inquiry"
This reverts commit 9420de59f5.

Reason: Turns out we want to keep this method.
2015-03-30 13:38:13 -03:00
Rafael Mendonça França
9420de59f5 Remove Array#inquiry
We are promoting too much a feature that will not be widler used.
So for now lets keep just the ArrayInquirer constructor.
2015-03-27 16:25:13 -03:00
George Claghorn
c64b99ecc9 Add ActiveSupport::ArrayInquirer and Array#inquiry
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
2015-03-24 13:33:01 -05:00