aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/hash
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #26905 from bogdanvlviv/docsAndrew White2016-11-131-1/+1
|\ | | | | Add missing `+` around a some literals.
| * Add missing `+` around a some literals.bogdanvlviv2016-10-271-1/+1
| | | | | | | | | | | | Mainly around `nil` [ci skip]
* | Add more rubocop rules about whitespacesRafael Mendonça França2016-10-292-4/+4
|/
* Use Hash#compact and Hash#compact! from Ruby 2.4Prathamesh Sonpatki2016-10-231-18/+22
| | | | | | - Ruby 2.4 has added Hash#compact and Hash#compact! so we can use it now. - Reference: https://bugs.ruby-lang.org/issues/11818 and https://bugs.ruby-lang.org/issues/12863.
* Add comment to remove code when we are in Ruby 2.4Rafael Mendonça França2016-10-141-0/+1
|
* Use built-in #transform_values when available.Jesús Burgos2016-10-141-2/+2
| | | | | | | | | | | | The methods Hash#transform_values and Hash#transform_values! have been implemented in Ruby and they'll be available as part of the standard library. Here's the link to the discussion in Ruby's issue tracker: https://bugs.ruby-lang.org/issues/12512 These methods are implemented in C so they're expected to perform better.
* Add three new rubocop rulesRafael Mendonça França2016-08-162-7/+7
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* code gardening: removes redundant selfsXavier Noria2016-08-081-2/+2
| | | | | | | | | A few have been left for aesthetic reasons, but have made a pass and removed most of them. Note that if the method `foo` returns an array, `foo << 1` is a regular push, nothing to do with assignments, so no self required.
* applies remaining conventions across the projectXavier Noria2016-08-062-14/+12
|
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-4/+4
|
* applies new string literal convention in activesupport/libXavier Noria2016-08-062-24/+24
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Improve Hash#compact! documentation and testsIgor Pstyga2016-06-031-5/+8
| | | | | | | Make it clear what should be returned when no changes were made to the hash. { c: true }.compact! # => nil
* Normalize whitespace for Hash#compact documentation [ci skip]Mark Lee2016-05-241-6/+6
| | | | This is a similar change that occurred for Hash#except in #21087.
* Support for unified Integer class in Ruby 2.4+Jeremy Daer2016-05-181-2/+1
| | | | | | | | Ruby 2.4 unifies Fixnum and Bignum into Integer: https://bugs.ruby-lang.org/issues/12005 * Forward compat with new unified Integer class in Ruby 2.4+. * Backward compat with separate Fixnum/Bignum in Ruby 2.2 & 2.3. * Drops needless Fixnum distinction in docs, preferring Integer.
* Change the Hash.to_xml with a lamda example Justin2016-04-191-1/+1
| | | | Update 'foo'.to_xml(lambda { |options, key| options[:builder].b(key) }) to {foo: lambda { |options, key| options[:builder].b(key) }}.to_xml
* Restore Hash#transform_keys behavior to always return a Hash instanceEmily2016-04-121-1/+1
|
* Fix nodoc to internal class error document some of themVipul A M2016-01-251-0/+2
| | | | | | | [ci skip] Fixes #20808 [Vipul A M & Julio Lopez]
* Merge pull request #21806 from kachick/fix-transformer-sizeEileen M. Uchitelle2015-11-072-4/+4
|\ | | | | Return a sized Enumerator from Hash#transform_values{!}
| * Return a sized Enumerator from Hash#{transform_values{!}|transform_keys{!}}Kenichi Kamiya2015-09-292-4/+4
| |
* | Merge pull request #16357 from gchan/hwia-respects-to-hash-defaultSean Griffin2015-10-291-1/+1
|\ \ | | | | | | | | | | | | `HashWithIndifferentAccess.new` respects the default value or proc on objects that respond to `#to_hash`
| * | `HashWithIndifferentAccess.new` respects the default value or proc on ↵Gordon Chan2014-07-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | objects that respond to `#to_hash`. Builds on the work of #12550 where `.new` will convert the object (that respond to `#to_hash`) to a hash and add that hash's keys and values to itself. This change will also make `.new` respect the default value or proc of objects that respond to `#to_hash`. In other words, this `.new` behaves exactly like `.new_from_hash_copying_default`. `.new_from_hash_copying_default` now simply invokes `.new` and any references to `.new_from_hash_copying_default` are replaced with `.new`. Added tests confirm behavior.
* | | Improve readability of docs by using code tag [ci skip]Prakash Laxkar2015-09-291-1/+1
| |/ |/|
* | Merge pull request #21782 from ronakjangir47/transform_values_docsRafael Mendonça França2015-09-282-8/+17
|\ \ | | | | | | Updated docs for transform_keys & transform_values
| * | Updated docs for transform_values [ci skip]Ronak Jangir2015-09-281-3/+8
| | |
| * | Updated docs for transform_keys [ci skip]Ronak Jangir2015-09-281-5/+9
| | |
* | | Speed up `Hash#transform_values` when emptySean Griffin2015-09-281-0/+1
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We're calling this function on an empty hash as part of copying the attribute set during dirty checking initialization. The new structure caused a performance regression on loading records from the database. This causes `User.all.to_a` to perform about 10% faster w/ 10k records. Calculating ------------------------------------- User.all - master 9.000 i/100ms User.all - sg-fix-ar-regression 8.000 i/100ms ------------------------------------------------- User.all - master 81.236 (± 7.4%) i/s - 405.000 User.all - sg-fix-ar-regression 89.716 (± 7.8%) i/s - 448.000
* | Fix the documentation of Hash#except method [ci skip]Mehmet Emin İNAÇ2015-08-031-8/+9
| | | | | | | | fix minor problems
* | Added documentation about passing custom disallowed types to Hash#from_xml ↵Prathamesh Sonpatki2015-06-181-1/+19
| | | | | | | | [ci skip]
* | Doc fixes [ci skip]Islam Wazery2015-03-071-1/+1
| |
* | Doc fix [ci skip]Islam Wazery2015-03-071-7/+7
| |
* | Replace `#=>` with `# =>` [ci skip]claudiob2014-12-171-1/+1
| | | | | | | | | | | | | | | | @rafaelfranca suggested in f7c7bcd9 that code examples should display the result after `# =>` and not after `#=>`. This commit replaces *all* the occurrences of `#=>` in the code documentation (mostly added by me :sob:) with the suggested `# =>`.
* | Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-291-4/+4
| |
* | added example of hash#except, and removed extra whitespaces [ci skip]Rishi Jain2014-11-072-5/+11
| |
* | fix typo [ci skip]Vijay Dev2014-11-041-1/+1
| |
* | fixed typo [ci skip]Rishi Jain2014-11-041-1/+1
| |
* | added example for hash slice method [ci skip]Rishi Jain2014-11-041-2/+8
|/
* Return an Enumerator if no block is givenErik Michaels-Ober2014-07-122-1/+5
|
* Don't construct a Proc if no block is givenErik Michaels-Ober2014-07-121-1/+1
|
* Add `Hash#map_values` to ActiveSupportSean Griffin2014-06-291-0/+21
| | | | | Didn't get a chance to convert existing code, I'll skim through the code base to make use of this later this afternoon.
* Fix documentation from #15669 [ci skip]Zachary Scott2014-06-171-3/+5
|
* [ci skip] fix doc for the Hash#assert_valid_keysAditya Kapoor2014-06-171-3/+3
|
* 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`
* Correct result, previously showing wrong resultAkshay Vishnoi2014-06-041-1/+1
|
* [ci skip] Correct output of Hash#symbolize_keysAkshay Vishnoi2014-05-311-2/+2
|
* Merge pull request #10887 from sakuro/deep_transform_keys_in_nested_arraysRafael Mendonça França2014-05-201-16/+38
|\ | | | | | | | | | | | | Hash#deep_*_keys(!) recurse into nested arrays. Conflicts: activesupport/CHANGELOG.md
| * Hash#deep_*_keys(!) recurse into nested arrays.OZAWA Sakuro2013-06-081-16/+38
| | | | | | | | | | | | | | | | | | | | | | Following methods now recursively transform nested arrays, too. * Hash#deep_transform_keys * Hash#deep_transform_keys! * Hash#deep_stringify_keys * Hash#deep_stringify_keys! * Hash#deep_symbolize_keys * Hash#deep_symbolize_keys!
* | Change 'a' to 'an' [ci skip]Santosh Wadghule2014-05-091-1/+1
| |
* | Merge pull request #12746 from coreyward/masterRafael Mendonça França2014-05-071-11/+22
|\ \ | | | | | | | | | Fix Hash#deep_merge bug and improve documentation — resolves #12738
| * | Fix Hash#deep_merge bug and improve documentation — resolves #12738Corey Ward2013-12-091-11/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | Previously merging into a hash with a falsy value would not result in the merge-block being called. The fix is simply to check for presence of the key in the hash. The documentation example for `deep_merge` now appropriately demonstrates what a deep merge does.