aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/array
Commit message (Collapse)AuthorAgeFilesLines
* [Active Support] require_relative => requireAkira Matsuda2017-10-212-7/+7
| | | | This basically reverts 8da30ad6be34339124ba4cb4e36aea260dda12bc
* [Active Support] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-117-0/+7
|
* Use frozen-string-literal in ActiveSupportKir Shatrov2017-07-097-0/+7
|
* [Active Support] require => require_relativeAkira Matsuda2017-07-012-7/+7
|
* Prevent aliases Array#append and Array#prependbogdanvlviv2017-04-021-2/+2
| | | | https://github.com/ruby/ruby/commit/f57d515d69b7a35477b9ba5d08fe117df1f1e275
* add missing comment out [ci skip]bogdanvlviv2017-01-201-1/+1
|
* `self.` is not needed when calling its own instance methodAkira Matsuda2017-01-051-1/+1
| | | | Actually, private methods cannot be called with `self.`, so it's not just redundant, it's a bad habit in Ruby
* Revert "Merge pull request #25811 from oss92/to_sentence_fallback_string"Rafael Mendonça França2016-11-141-8/+2
| | | | | | | | This reverts commit bad3a120f1690f393d8f6204b3ceee60f0ce707b, reversing changes made to 2384317465ccb1dfca456a2b7798714b99f32711. Reason: Adding a new option in the API for something that can be done with a `#presence` check could do.
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-1/+1
|
* modernizes hash syntax in activesupportXavier Noria2016-08-061-3/+3
|
* applies new string literal convention in activesupport/libXavier Noria2016-08-062-15/+15
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Added :fallback_string option to Array#to_sentenceoss922016-07-131-2/+8
|
* Array#split refactoring for case with blocklvl0nax2016-05-061-11/+6
| | | | | | | | | | | | | Calculating ------------------------------------- before 26.319k i/100ms after 29.414k i/100ms ------------------------------------------------- before 350.623k (± 1.6%) i/s - 1.763M after 416.227k (± 1.4%) i/s - 2.088M Comparison: after: 416226.8 i/s before: 350622.8 i/s - 1.19x slower
* Little perfomance fix for Array#split.lvl0nax2016-04-261-10/+6
| | | | | | | | | Calculating ------------------------------------- before 40.770k i/100ms after 58.464k i/100ms ------------------------------------------------- before 629.568k (± 5.0%) i/s - 3.180M after 1.159M (± 4.5%) i/s - 5.788M
* rename to 'second_to_last' and 'third_to_last'Brian Christian2016-02-101-4/+4
|
* allow Array.penultimate and Array.antepenultiate access methodsBrian Christian2016-02-091-0/+14
|
* Added Examples in docs for internal behavior of Array#to_formatted_s [ci skip]Ronak Jangir2015-09-191-1/+3
|
* Correct ArgumentError message in ActiveSupport conversions docs [ci skip]amitkumarsuroliya2015-09-181-1/+1
| | | This was happened after this commit https://github.com/rails/rails/commit/2ebf47aea21ff8ac10681e53e78dd7a0e5c31c6e
* Merge pull request #19814 from y-yagi/array_inquiryRafael Mendonça França2015-04-191-0/+2
|\ | | | | add missing require for ArrayInquirer
| * add missing require for ArrayInquireryuuji.yaginuma2015-04-191-0/+2
| |
* | Merge pull request #19799 from yui-knk/fix/wrap_doc2Arthur Nogueira Neves2015-04-191-3/+4
|\ \ | |/ |/| [ci skip] Fix docs and guide about 'Array.wrap'
| * [ci skip] Fix docs and guide about 'Array.wrap'yui-knk2015-04-191-3/+4
| |
* | [ci skip] Replace `list` with `array`yui-knk2015-04-181-1/+1
|/
* Revert "Remove Array#inquiry"Rafael Mendonça França2015-03-301-0/+15
| | | | | | This reverts commit 9420de59f5b7f5ceac77e28e6c326ec145f71f80. Reason: Turns out we want to keep this method.
* Remove Array#inquiryRafael Mendonça França2015-03-271-15/+0
| | | | | We are promoting too much a feature that will not be widler used. So for now lets keep just the ArrayInquirer constructor.
* Add ActiveSupport::ArrayInquirer and Array#inquiryGeorge Claghorn2015-03-241-0/+15
| | | | | | | | | | | | | | | | | | | | | | 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
* Make sure Array#to_sentence always returns a StringDavid Cornu2015-03-231-1/+1
|
* Move Array#without from Grouping to Access concern and add dedicated test ↵David Heinemeier Hansson2015-03-022-12/+12
| | | | (relates to #19157)
* Add Enumerable#withoutTodd Bealmear2015-03-011-0/+12
|
* A little performance improvement using 'take' method over 'first'Santosh Wadghule2015-01-161-1/+1
|
* Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-291-1/+1
|
* Avoid creating range objects (take II)Akira Matsuda2014-10-251-1/+5
|
* Raise a descriptive error if non-positive integer passed to in_groups_of.Xavier Shay2014-07-301-0/+5
| | | | | | | | | | This is more consistent than the current behaviour of raising a `ZeroDivisionError: divided by 0` error when 0 is given, which can be non-obvious especially if `in_groups_of` is part of a longer chain of methods. The negative case was ok - "ArgumentError: invalid slice size" - but this error is clearer still.
* Revert "remove unnecssary require of `to_param`, as `to_query` is already ↵Rafael Mendonça França2014-06-111-0/+1
| | | | | | | | | | | | | | | | | | | | | require `to_param`" Revert "No need to require to_param, it is already required in to_query.rb" This reverts commits ccdd97662e1fb00c23c90d59f65c091904959561 and d697ee14264a90a39cdbe87857656d8b314ac9b7. Reason by @jeremy: These requires are not for implementation dependency. They ensure that requiring array conversions provides to_query, to_param, and other array conversion behaviors. The fact that to_query is implemented in terms of to_param is just a coincidence. If to_query removed its to_param require, then someone requiring array conversions would no longer have to_param available. This change removes these intentional dependencies on to_param in favor of implementation side effects—an undesirable move that's susceptible to regression.
* remove unnecssary require of `to_param`, as `to_query` is already require ↵Kuldeep Aggarwal2014-06-121-1/+0
| | | | `to_param`
* Merge pull request #15276 from kuldeepaggarwal/fix-array-toRafael Mendonça França2014-05-231-1/+3
|\ | | | | Array#to now accept negative position also.
| * revert 96525d63Kuldeep Aggarwal2014-05-231-1/+3
| | | | | | | | `Array#to` is working for negative position
* | add test cases for negative position in Array#fromKuldeep Aggarwal2014-05-231-0/+2
|/
* Typo fixes [ci skip]Akshay Vishnoi2013-11-301-2/+2
|
* Merge pull request #12842 from kuldeepaggarwal/array_splitGuillermo Iguaran2013-11-111-3/+3
|\ | | | | Speed up Array#split when block is passed
| * Speed up Array#splitKD2013-11-111-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | Ruby 2.0.0p247 Rehearsal --------------------------------------- old 10.670000 0.150000 10.820000 ( 10.822651) new 8.520000 0.050000 8.570000 ( 8.571825) ----------------------------- total: 19.390000sec user system total real old 10.620000 0.170000 10.790000 ( 10.790409) new 8.570000 0.110000 8.680000 ( 8.686051)
* | Merge pull request #12841 from kuldeepaggarwal/in-group-documentationYves Senn2013-11-101-1/+1
|\ \ | |/ |/| Array#in_groups: documentation updated [ci skip]
| * Array#in_groups: documentation updatedKD2013-11-111-1/+1
| |
* | Array#split preserving the calling arrayKD2013-11-111-2/+2
|/
* Add Rdoc document for Array#forty_twoutenmiki2013-10-311-0/+2
|
* Merge branch 'master' of github.com:rails/docrailsVijay Dev2013-07-211-17/+2
|\
| * Array#to_formatted_s does not call each element's to_s anymoreAkira Matsuda2013-07-111-17/+2
| | | | | | | | Array#to_s calls each element's inspect since ruby 1.9
* | Simplify Array#in_groups_of codeAkira Matsuda2013-07-101-3/+1
| |
* | Speed up Array#splitAkira Matsuda2013-07-101-6/+20
|/ | | | | | | Benchmark: user system total real old 0.510000 0.000000 0.510000 ( 0.506749) new 0.330000 0.000000 0.330000 ( 0.336187)
* Remove deprecated Array#uniq_by and Array#uniq_by!Carlos Antonio da Silva2013-07-011-19/+0
| | | | Use native Array#uniq and Array#uniq! instead.