aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2015-03-30 13:38:13 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2015-03-30 13:38:13 -0300
commitb5c35023bd422c62973d003378b7185dfe221919 (patch)
treecfd8e337e80b4f0b72e4a01a17dd88179919c436 /activesupport/lib/active_support/core_ext
parentcb012467214f6e4bb1ac3987554bb75020b4796b (diff)
downloadrails-b5c35023bd422c62973d003378b7185dfe221919.tar.gz
rails-b5c35023bd422c62973d003378b7185dfe221919.tar.bz2
rails-b5c35023bd422c62973d003378b7185dfe221919.zip
Revert "Remove Array#inquiry"
This reverts commit 9420de59f5b7f5ceac77e28e6c326ec145f71f80. Reason: Turns out we want to keep this method.
Diffstat (limited to 'activesupport/lib/active_support/core_ext')
-rw-r--r--activesupport/lib/active_support/core_ext/array.rb1
-rw-r--r--activesupport/lib/active_support/core_ext/array/inquiry.rb15
2 files changed, 16 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/array.rb b/activesupport/lib/active_support/core_ext/array.rb
index 7d0c1e4c8d..7551551bd7 100644
--- a/activesupport/lib/active_support/core_ext/array.rb
+++ b/activesupport/lib/active_support/core_ext/array.rb
@@ -4,3 +4,4 @@ require 'active_support/core_ext/array/conversions'
require 'active_support/core_ext/array/extract_options'
require 'active_support/core_ext/array/grouping'
require 'active_support/core_ext/array/prepend_and_append'
+require 'active_support/core_ext/array/inquiry'
diff --git a/activesupport/lib/active_support/core_ext/array/inquiry.rb b/activesupport/lib/active_support/core_ext/array/inquiry.rb
new file mode 100644
index 0000000000..de623c466c
--- /dev/null
+++ b/activesupport/lib/active_support/core_ext/array/inquiry.rb
@@ -0,0 +1,15 @@
+class Array
+ # Wraps the array in an +ArrayInquirer+ object, which gives a friendlier way
+ # to check its string-like contents.
+ #
+ # pets = [:cat, :dog].inquiry
+ #
+ # pets.cat? # => true
+ # pets.ferret? # => false
+ #
+ # pets.any?(:cat, :ferret) # => true
+ # pets.any?(:ferret, :alligator) # => false
+ def inquiry
+ ActiveSupport::ArrayInquirer.new(self)
+ end
+end