aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/hash
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* | | Minor grammer, code conventions fix [ci skip]Zoltan Kiss2014-03-151-2/+1
| | | | | | | | | | | | | | | Conflicts: activesupport/lib/active_support/core_ext/hash/conversions.rb
* | | Merge pull request #13709 from akshay-vishnoi/typoYves Senn2014-01-141-1/+1
|\ \ \ | | | | | | | | [ci skip] Grammar correction
| * | | [ci skip] Grammar correctionAkshay Vishnoi2014-01-141-1/+1
| |/ /
* | | Adding Hash#compact and Hash#compact! methodstinogomes2014-01-091-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Adding Hash#compact and Hash#compact! methods * Using Ruby 1.9 syntax on documentation * Updating guides for `Hash#compact` and `Hash#compact!` methods * Updating CHANGELOG for ActiveSupport * Removing unecessary protected method and lambda for `Hash#compact` implementations * Performing `Hash#compact` implementation - https://gist.github.com/tinogomes/8332883 * fixing order position * Fixing typo
* | | Merge branch 'master' of github.com:lifo/docrailsVijay Dev2013-12-202-7/+7
|\ \ \ | |/ / |/| |
| * | Typos. return -> returns. [ci skip]Lauro Caetano2013-12-032-7/+7
| | |
* | | Tidy up previous commit, fix message assertion and improve testsCarlos Antonio da Silva2013-12-031-1/+3
| | |
* | | Modify the Hash#assert_valid_keys error message so that it shows the valid ↵Nerian2013-12-031-3/+3
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | keys. Also, show the wrong value as it was entered. { :failore => "stuff", :funny => "business" }.assert_valid_keys([ :failure, :funny ]) => ArgumentError: Unknown key: failore { 'failore' => "stuff", :funny => "business" }.assert_valid_keys([ :failure, :funny ]) => ArgumentError: Unknown key: failore { 'failore' => "stuff", :funny => "business" }.assert_valid_keys([ :failure, :funny ]) => ArgumentError: Unknown key: "failore". Valid keys are: :failure, :funny { :failore => "stuff", :funny => "business" }.assert_valid_keys([ :failure, :funny ]) => ArgumentError: Unknown key: :failore. Valid keys are: :failure, :funny Conflicts: activerecord/CHANGELOG.md Closes #11624.
* | Merge remote-tracking branch 'docrails/master'Xavier Noria2013-11-242-4/+4
|\ \ | | | | | | | | | | | | | | | Conflicts: activesupport/lib/active_support/core_ext/hash/deep_merge.rb activesupport/lib/active_support/core_ext/hash/keys.rb
| * | Change syntax format for example returned valuesPrem Sichanugrist2013-11-112-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | According to our guideline, we leave 1 space between `#` and `=>`, so we want `# =>` instead of `#=>`. Thanks to @fxn for the suggestion. [ci skip]
* | | documentation updated for Hashes [ci skip]KD2013-11-114-14/+18
|/ /
* | slice! should not remove default hash value/procAntonio Santos2013-10-241-0/+2
| |
* | Revert "Merge branch 'master' of github.com:rails/docrails"Vijay Dev2013-08-171-0/+1
| | | | | | | | | | | | | | This reverts commit 70d6e16fbad75b89dd1798ed697e7732b8606fa3, reversing changes made to ea4db3bc078fb3093ecdddffdf4f2f4ff3e1e8f9. Seems to be a code merge done by mistake.
* | Merge pull request #11625 from phstc/minor-refactor-code-gardener-groupingRafael Mendonça França2013-07-271-1/+0
|\ \ | | | | | | Minor refactor - Uses Enumerable#to_a instead of iterate and add to an array