aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/hash
Commit message (Collapse)AuthorAgeFilesLines
* hash_conversion itself does not at all depend on time extensionsAkira Matsuda2019-08-021-1/+0
|
* It may be better to explicitly require 'object/try' where we call `try`Akira Matsuda2019-08-011-0/+1
| | | | | | In most cases it works now without explicit require because it's accidentally required through active_support/core_ext/date_and_time/calculations.rb where we still call `try`, but that would stop working if we changed the Calculations implementation and remove the require call there.
* Change commentsEdu Depetris2019-05-251-2/+2
|
* Speed improvement for Hash#exceptTimo Schilling2019-03-291-1/+1
|
* Remove redundant returning `object`Ryuta Kamizono2019-02-091-1/+0
| | | | `object.transform_values!` returns `object` itself.
* Use Ruby 2.4+ native transform_values(!)Kasper Timm Hansen2019-02-081-7/+2
|
* Add 'Hash#deep_transform_values', and 'Hash#deep_transform_values!'Guillermo Iguaran2019-02-081-0/+52
|
* Follow up #34754bogdanvlviv2018-12-202-2/+2
| | | | | | | - Fix a few deprecation warnings - Remove testing of `Hash#slice` - Imporve test of `Hash#slice!` - Remove mention about `Hash#slice` from the guide
* Use native `Array#append`, `Array#prepend`, `Hash#transform_keys`, and ↵Ryuta Kamizono2018-12-201-29/+0
| | | | | | | | | | `Hash#transform_keys!` Since Rails 6 requires Ruby 2.5. https://github.com/ruby/ruby/blob/ruby_2_5/NEWS Follow up #34754.
* Require Ruby 2.5 for Rails 6.Kasper Timm Hansen2018-12-191-23/+0
| | | | | | | | | | Generally followed the pattern for https://github.com/rails/rails/pull/32034 * Removes needless CI configs for 2.4 * Targets 2.5 in rubocop * Updates existing CHANGELOG entries for fewer merge conflicts * Removes Hash#slice extension as that's inlined on Ruby 2.5. * Removes the need for send on define_method in MethodCallAssertions.
* Remove odd spaces [ci skip]Ryuta Kamizono2018-11-211-2/+2
|
* Improve documentation for Hash#slice!Daniel Lopez 👾2018-11-211-2/+3
|
* Deprecate `active_support/core_ext/hash/compact`yuuji.yaginuma2018-03-021-26/+2
| | | | | Ruby 2.4+ provides `Hash#compact` and `Hash#compact!` natively, so `active_support/core_ext/hash/compact` is no longer necessary.
* Rails 6 requires Ruby 2.4.1+Jeremy Daer2018-02-171-29/+2
| | | | | | Skipping over 2.4.0 to sidestep the `"symbol_from_string".to_sym.dup` bug. References #32028
* Enable autocorrect for `Lint/EndAlignment` copKoichi ITO2018-01-181-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ### Summary This PR changes .rubocop.yml. Regarding the code using `if ... else ... end`, I think the coding style that Rails expects is as follows. ```ruby var = if cond a else b end ``` However, the current .rubocop.yml setting does not offense for the following code. ```ruby var = if cond a else b end ``` I think that the above code expects offense to be warned. Moreover, the layout by autocorrect is unnatural. ```ruby var = if cond a else b end ``` This PR adds a setting to .rubocop.yml to make an offense warning and autocorrect as expected by the coding style. And this change also fixes `case ... when ... end` together. Also this PR itself is an example that arranges the layout using `rubocop -a`. ### Other Information Autocorrect of `Lint/EndAlignment` cop is `false` by default. https://github.com/bbatsov/rubocop/blob/v0.51.0/config/default.yml#L1443 This PR changes this value to `true`. Also this PR has changed it together as it is necessary to enable `Layout/ElseAlignment` cop to make this behavior.
* [Active Support] require_relative => requireAkira Matsuda2017-10-212-10/+10
| | | | This basically reverts 8da30ad6be34339124ba4cb4e36aea260dda12bc
* Let Hash#slice return a HashAkira Matsuda2017-10-211-1/+1
| | | | | | | In order to keep this method compatible with the Ruby 2.5 version of Hash#slice. This bahavior is actually slightly incompatibile with previous versions of Active Support but it might not cause a real problem, since HWIA, the biggest use case of Hash subclassing here, already overrides `slice` to return another HWIA.
* Move HWIA specific logic for slice and slice! to HWIA classAkira Matsuda2017-10-211-2/+0
|
* Hash#slice is in Ruby 2.5+Akira Matsuda2017-10-211-1/+1
| | | | since r60229
* Hash#transform_keys is in Ruby 2.5+Akira Matsuda2017-09-011-2/+2
| | | | since r59328
* faster implementation of Hash#deep_mergeM. Simon Borg2017-08-161-12/+6
| | | | | | | | | | | | add missing newline call #deep_merge instead of #dup.deep_merge! make variable and parameter naming more consistent change `_key` to `key` faster implementation of Hash#deep_merge
* Merge branch 'master' into make-reverse-merge-bang-order-consistentSean Griffin2017-07-179-10/+30
|\
| * [Active Support] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-119-0/+9
| |
| * Use frozen-string-literal in ActiveSupportKir Shatrov2017-07-099-0/+9
| |
| * [Active Support] require => require_relativeAkira Matsuda2017-07-012-10/+10
| |
| * Add aliases for reverse_merge to with_defaultsMatt Casper2017-03-291-0/+2
| | | | | | | | | | | | In the context of controller parameters, reverse_merge is commonly used to provide defaults for user input. Having an alias to reverse_merge called with_defaults feels more idiomatic for Rails.
* | Make the order of Hash#reverse_merge! consistent with HashWithIndifferentAccessErol Fornoles2017-03-061-2/+1
|/
* 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