hashie 4.0.0 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +213 -187
  3. data/CONTRIBUTING.md +13 -6
  4. data/README.md +33 -9
  5. data/UPGRADING.md +5 -5
  6. data/hashie.gemspec +11 -6
  7. data/lib/hashie.rb +1 -0
  8. data/lib/hashie/extensions/dash/property_translation.rb +1 -1
  9. data/lib/hashie/extensions/deep_merge.rb +18 -1
  10. data/lib/hashie/extensions/mash/permissive_respond_to.rb +61 -0
  11. data/lib/hashie/extensions/parsers/yaml_erb_parser.rb +19 -2
  12. data/lib/hashie/extensions/ruby_version_check.rb +5 -1
  13. data/lib/hashie/mash.rb +31 -26
  14. data/lib/hashie/utils.rb +28 -0
  15. data/lib/hashie/version.rb +1 -1
  16. metadata +16 -131
  17. data/spec/hashie/array_spec.rb +0 -29
  18. data/spec/hashie/clash_spec.rb +0 -70
  19. data/spec/hashie/dash_spec.rb +0 -608
  20. data/spec/hashie/extensions/autoload_spec.rb +0 -24
  21. data/spec/hashie/extensions/coercion_spec.rb +0 -648
  22. data/spec/hashie/extensions/dash/coercion_spec.rb +0 -13
  23. data/spec/hashie/extensions/dash/indifferent_access_spec.rb +0 -84
  24. data/spec/hashie/extensions/deep_fetch_spec.rb +0 -97
  25. data/spec/hashie/extensions/deep_find_spec.rb +0 -144
  26. data/spec/hashie/extensions/deep_locate_spec.rb +0 -138
  27. data/spec/hashie/extensions/deep_merge_spec.rb +0 -74
  28. data/spec/hashie/extensions/ignore_undeclared_spec.rb +0 -48
  29. data/spec/hashie/extensions/indifferent_access_spec.rb +0 -295
  30. data/spec/hashie/extensions/indifferent_access_with_rails_hwia_spec.rb +0 -208
  31. data/spec/hashie/extensions/key_conversion_spec.rb +0 -12
  32. data/spec/hashie/extensions/mash/define_accessors_spec.rb +0 -90
  33. data/spec/hashie/extensions/mash/keep_original_keys_spec.rb +0 -46
  34. data/spec/hashie/extensions/mash/safe_assignment_spec.rb +0 -50
  35. data/spec/hashie/extensions/mash/symbolize_keys_spec.rb +0 -39
  36. data/spec/hashie/extensions/merge_initializer_spec.rb +0 -23
  37. data/spec/hashie/extensions/method_access_spec.rb +0 -233
  38. data/spec/hashie/extensions/strict_key_access_spec.rb +0 -109
  39. data/spec/hashie/extensions/stringify_keys_spec.rb +0 -124
  40. data/spec/hashie/extensions/symbolize_keys_spec.rb +0 -131
  41. data/spec/hashie/hash_spec.rb +0 -123
  42. data/spec/hashie/mash_spec.rb +0 -1077
  43. data/spec/hashie/parsers/yaml_erb_parser_spec.rb +0 -46
  44. data/spec/hashie/rash_spec.rb +0 -83
  45. data/spec/hashie/trash_spec.rb +0 -334
  46. data/spec/hashie/utils_spec.rb +0 -25
  47. data/spec/hashie/version_spec.rb +0 -7
  48. data/spec/hashie_spec.rb +0 -13
  49. data/spec/integration/elasticsearch/integration_spec.rb +0 -41
  50. data/spec/integration/omniauth-oauth2/app.rb +0 -52
  51. data/spec/integration/omniauth-oauth2/integration_spec.rb +0 -26
  52. data/spec/integration/omniauth-oauth2/some_site.rb +0 -38
  53. data/spec/integration/omniauth/app.rb +0 -11
  54. data/spec/integration/omniauth/integration_spec.rb +0 -38
  55. data/spec/integration/rails-without-dependency/integration_spec.rb +0 -15
  56. data/spec/integration/rails/app.rb +0 -40
  57. data/spec/integration/rails/integration_spec.rb +0 -47
  58. data/spec/spec_helper.rb +0 -23
  59. data/spec/support/integration_specs.rb +0 -36
  60. data/spec/support/logger.rb +0 -24
  61. data/spec/support/module_context.rb +0 -11
  62. data/spec/support/ruby_version_check.rb +0 -6
@@ -1,16 +1,16 @@
1
1
  Contributing to Hashie
2
2
  ======================
3
3
 
4
- Hashie is work of [many contributors](https://github.com/intridea/hashie/graphs/contributors). You're encouraged to submit [pull requests](https://github.com/intridea/hashie/pulls), [propose features and discuss issues](https://github.com/intridea/hashie/issues).
4
+ Hashie is work of [many contributors](https://github.com/hashie/hashie/graphs/contributors). You're encouraged to submit [pull requests](https://github.com/hashie/hashie/pulls), [propose features and discuss issues](https://github.com/hashie/hashie/issues).
5
5
 
6
6
  #### Fork the Project
7
7
 
8
- Fork the [project on Github](https://github.com/intridea/hashie) and check out your copy.
8
+ Fork the [project on Github](https://github.com/hashie/hashie) and check out your copy.
9
9
 
10
10
  ```
11
11
  git clone https://github.com/contributor/hashie.git
12
12
  cd hashie
13
- git remote add upstream https://github.com/intridea/hashie.git
13
+ git remote add upstream https://github.com/hashie/hashie.git
14
14
  ```
15
15
 
16
16
  #### Create a Topic Branch
@@ -23,12 +23,19 @@ git pull upstream master
23
23
  git checkout -b my-feature-branch
24
24
  ```
25
25
 
26
- #### Bundle Install and Test
26
+ #### Install dependencies
27
+
28
+ You can use the setup script to install dependencies for the gem and its integration tests.
29
+
30
+ ```
31
+ bin/setup
32
+ ```
33
+
34
+ #### Test
27
35
 
28
36
  Ensure that you can build the project and run tests.
29
37
 
30
38
  ```
31
- bundle install
32
39
  bundle exec rake
33
40
  ```
34
41
 
@@ -105,7 +112,7 @@ git push origin my-feature-branch -f
105
112
  Update the [CHANGELOG](CHANGELOG.md) with the pull request number. A typical entry looks as follows.
106
113
 
107
114
  ```
108
- * [#123](https://github.com/intridea/hashie/pull/123): Reticulated splines - [@contributor](https://github.com/contributor).
115
+ * [#123](https://github.com/hashie/hashie/pull/123): Reticulated splines - [@contributor](https://github.com/contributor).
109
116
  ```
110
117
 
111
118
  Amend your previous commit and force push the changes.
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Hashie
2
2
 
3
- [![Join the chat at https://gitter.im/intridea/hashie](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/intridea/hashie?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
3
+ [![Join the chat at https://gitter.im/hashie/hashie](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/hashie/hashie?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4
4
  [![Gem Version](http://img.shields.io/gem/v/hashie.svg)](http://badge.fury.io/rb/hashie)
5
- [![Build Status](http://img.shields.io/travis/intridea/hashie.svg)](https://travis-ci.org/intridea/hashie)
6
- [![Test Coverage](https://api.codeclimate.com/v1/badges/7a0b42c8a22c945571fd/test_coverage)](https://codeclimate.com/github/intridea/hashie/test_coverage)
7
- [![Maintainability](https://api.codeclimate.com/v1/badges/7a0b42c8a22c945571fd/maintainability)](https://codeclimate.com/github/intridea/hashie/maintainability)
5
+ [![Build Status](http://img.shields.io/travis/hashie/hashie.svg)](https://travis-ci.org/hashie/hashie)
6
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/7a0b42c8a22c945571fd/test_coverage)](https://codeclimate.com/github/hashie/hashie/test_coverage)
7
+ [![Maintainability](https://api.codeclimate.com/v1/badges/7a0b42c8a22c945571fd/maintainability)](https://codeclimate.com/github/hashie/hashie/maintainability)
8
8
 
9
9
  Hashie is a growing collection of tools that extend Hashes and make them more useful.
10
10
 
@@ -16,9 +16,9 @@ Hashie is available as a RubyGem:
16
16
  $ gem install hashie
17
17
  ```
18
18
 
19
- ## Upgrading
19
+ ## Stable Release
20
20
 
21
- You're reading the documentation for the stable release of Hashie, 4.0.0. Please read [UPGRADING](UPGRADING.md) when upgrading from a previous version.
21
+ You're reading the documentation for the stable release of Hashie, 4.1.0.(https://github.com/hashie/hashie/blob/v4.1.0/README.md).
22
22
 
23
23
  ## Hash Extensions
24
24
 
@@ -658,6 +658,30 @@ mash['string_key'] #=> 'string'
658
658
  mash[:string_key] #=> 'string'
659
659
  ```
660
660
 
661
+ ### Mash Extension: PermissiveRespondTo
662
+
663
+ By default, Mash only states that it responds to built-in methods, affixed methods (e.g. setters, underbangs, etc.), and keys that it currently contains. That means it won't state that it responds to a getter for an unset key, as in the following example:
664
+
665
+ ```ruby
666
+ mash = Hashie::Mash.new(a: 1)
667
+ mash.respond_to? :b #=> false
668
+ ```
669
+
670
+ This means that by default Mash is not a perfect match for use with a SimpleDelegator since the delegator will not forward messages for unset keys to the Mash even though it can handle them.
671
+
672
+ In order to have a SimpleDelegator-compatible Mash, you can use the `PermissiveRespondTo` extension to make Mash respond to anything.
673
+
674
+ ```ruby
675
+ class PermissiveMash < Hashie::Mash
676
+ include Hashie::Extensions::Mash::PermissiveRespondTo
677
+ end
678
+
679
+ mash = PermissiveMash.new(a: 1)
680
+ mash.respond_to? :b #=> true
681
+ ```
682
+
683
+ This comes at the cost of approximately 20% performance for initialization and setters and 19KB of permanent memory growth for each such class that you create.
684
+
661
685
  ### Mash Extension: SafeAssignment
662
686
 
663
687
  This extension can be mixed into a Mash to guard the attempted overwriting of methods by property setters. When mixed in, the Mash will raise an `ArgumentError` if you attempt to write a property with the same name as an existing method.
@@ -873,7 +897,7 @@ class DataModelHash < Hashie::Dash
873
897
  end
874
898
 
875
899
  model = DataModelHash.new(id: '123', created: '2014-04-25 22:35:28')
876
- model.id.class #=> Fixnum
900
+ model.id.class #=> Integer (Fixnum if you are using Ruby 2.3 or lower)
877
901
  model.created_at.class #=> Time
878
902
  ```
879
903
 
@@ -942,7 +966,7 @@ this will produce the following
942
966
 
943
967
  ```ruby
944
968
  result = Result.new(id: '123', creation_date: '2012-03-30 17:23:28')
945
- result.id.class # => Fixnum
969
+ result.id.class # => Integer (Fixnum if you are using Ruby 2.3 or lower)
946
970
  result.created_at.class # => Time
947
971
  ```
948
972
 
@@ -1009,6 +1033,6 @@ See [CONTRIBUTING.md](CONTRIBUTING.md)
1009
1033
 
1010
1034
  ## Copyright
1011
1035
 
1012
- Copyright (c) 2009-2014 Intridea, Inc. (http://intridea.com/) and [contributors](https://github.com/intridea/hashie/graphs/contributors).
1036
+ Copyright (c) 2009-2014 Intridea, Inc. (http://intridea.com/) and [contributors](https://github.com/hashie/hashie/graphs/contributors).
1013
1037
 
1014
1038
  MIT License. See [LICENSE](LICENSE) for details.
@@ -143,7 +143,7 @@ h.abb? # => false
143
143
 
144
144
  #### Possible coercion changes
145
145
 
146
- The improvements made to coercions in version 3.2.1 [issue #200](https://github.com/intridea/hashie/pull/200) do not break the documented API, but are significant enough that changes may effect undocumented side-effects. Applications that depended on those side-effects will need to be updated.
146
+ The improvements made to coercions in version 3.2.1 [issue #200](https://github.com/hashie/hashie/pull/200) do not break the documented API, but are significant enough that changes may effect undocumented side-effects. Applications that depended on those side-effects will need to be updated.
147
147
 
148
148
  **Change**: Type coercion no longer creates new objects if the input matches the target type. Previously coerced properties always resulted in the creation of a new object, even when it wasn't necessary. This had the effect of a `dup` or `clone` on coerced properties but not uncoerced ones.
149
149
 
@@ -159,7 +159,7 @@ Applications that were attempting to rescuing the internal errors should be upda
159
159
 
160
160
  #### Compatibility with Rails 4 Strong Parameters
161
161
 
162
- Version 2.1 introduced support to prevent default Rails 4 mass-assignment protection behavior. This was [issue #89](https://github.com/intridea/hashie/issues/89), resolved in [#104](https://github.com/intridea/hashie/pull/104). In version 2.2 this behavior has been removed in [#147](https://github.com/intridea/hashie/pull/147) in favor of a mixin and finally extracted into a separate gem in Hashie 3.0.
162
+ Version 2.1 introduced support to prevent default Rails 4 mass-assignment protection behavior. This was [issue #89](https://github.com/hashie/hashie/issues/89), resolved in [#104](https://github.com/hashie/hashie/pull/104). In version 2.2 this behavior has been removed in [#147](https://github.com/hashie/hashie/pull/147) in favor of a mixin and finally extracted into a separate gem in Hashie 3.0.
163
163
 
164
164
  To enable 2.1 compatible behavior with Rails 4, use the [hashie_rails](http://rubygems.org/gems/hashie_rails) gem.
165
165
 
@@ -167,7 +167,7 @@ To enable 2.1 compatible behavior with Rails 4, use the [hashie_rails](http://ru
167
167
  gem 'hashie_rails'
168
168
  ```
169
169
 
170
- See [#154](https://github.com/intridea/hashie/pull/154) and [Mash and Rails 4 Strong Parameters](README.md#mash-and-rails-4-strong-parameters) for more details.
170
+ See [#154](https://github.com/hashie/hashie/pull/154) and [Mash and Rails 4 Strong Parameters](README.md#mash-and-rails-4-strong-parameters) for more details.
171
171
 
172
172
  #### Key Conversions in Hashie::Dash and Hashie::Trash
173
173
 
@@ -195,7 +195,7 @@ p.inspect # => { 'name' => 'dB.' }
195
195
  p.to_hash # => { 'name' => 'dB.' }
196
196
  ```
197
197
 
198
- It was not possible to achieve the behavior of preserving keys, as described in [issue #151](https://github.com/intridea/hashie/issues/151).
198
+ It was not possible to achieve the behavior of preserving keys, as described in [issue #151](https://github.com/hashie/hashie/issues/151).
199
199
 
200
200
  Version 2.2 does not perform this conversion by default.
201
201
 
@@ -242,4 +242,4 @@ instance.to_hash # => { :first => 'First', "last" => 'Last' }
242
242
 
243
243
  The behavior with `symbolize_keys` and `stringify_keys` is unchanged.
244
244
 
245
- See [#152](https://github.com/intridea/hashie/pull/152) for more information.
245
+ See [#152](https://github.com/hashie/hashie/pull/152) for more information.
@@ -7,17 +7,22 @@ Gem::Specification.new do |gem|
7
7
  gem.email = ['michael@intridea.com', 'jollyjerry@gmail.com']
8
8
  gem.description = 'Hashie is a collection of classes and mixins that make hashes more powerful.'
9
9
  gem.summary = 'Your friendly neighborhood hash library.'
10
- gem.homepage = 'https://github.com/intridea/hashie'
10
+ gem.homepage = 'https://github.com/hashie/hashie'
11
11
  gem.license = 'MIT'
12
12
 
13
13
  gem.require_paths = ['lib']
14
14
  gem.files = %w[.yardopts CHANGELOG.md CONTRIBUTING.md LICENSE README.md UPGRADING.md]
15
15
  gem.files += %w[Rakefile hashie.gemspec]
16
16
  gem.files += Dir['lib/**/*.rb']
17
- gem.files += Dir['spec/**/*.rb']
18
- gem.test_files = Dir['spec/**/*.rb']
19
17
 
20
- gem.add_development_dependency 'rake', '< 11'
21
- gem.add_development_dependency 'rspec', '~> 3.0'
22
- gem.add_development_dependency 'rspec-pending_for', '~> 0.1'
18
+ if gem.respond_to?(:metadata)
19
+ gem.metadata = {
20
+ 'bug_tracker_uri' => 'https://github.com/hashie/hashie/issues',
21
+ 'changelog_uri' => 'https://github.com/hashie/hashie/blob/master/CHANGELOG.md',
22
+ 'documentation_uri' => 'https://www.rubydoc.info/gems/hashie',
23
+ 'source_code_uri' => 'https://github.com/hashie/hashie'
24
+ }
25
+ end
26
+
27
+ gem.add_development_dependency 'bundler'
23
28
  end
@@ -45,6 +45,7 @@ module Hashie
45
45
 
46
46
  module Mash
47
47
  autoload :KeepOriginalKeys, 'hashie/extensions/mash/keep_original_keys'
48
+ autoload :PermissiveRespondTo, 'hashie/extensions/mash/permissive_respond_to'
48
49
  autoload :SafeAssignment, 'hashie/extensions/mash/safe_assignment'
49
50
  autoload :SymbolizeKeys, 'hashie/extensions/mash/symbolize_keys'
50
51
  autoload :DefineAccessors, 'hashie/extensions/mash/define_accessors'
@@ -35,7 +35,7 @@ module Hashie
35
35
  # end
36
36
  #
37
37
  # model = DataModelHash.new(id: '123', created: '2014-04-25 22:35:28')
38
- # model.id.class #=> Fixnum
38
+ # model.id.class #=> Integer (Fixnum if you are using Ruby 2.3 or lower)
39
39
  # model.created_at.class #=> Time
40
40
  module PropertyTranslation
41
41
  def self.included(base)
@@ -3,7 +3,7 @@ module Hashie
3
3
  module DeepMerge
4
4
  # Returns a new hash with +self+ and +other_hash+ merged recursively.
5
5
  def deep_merge(other_hash, &block)
6
- copy = dup
6
+ copy = _deep_dup(self)
7
7
  copy.extend(Hashie::Extensions::DeepMerge) unless copy.respond_to?(:deep_merge!)
8
8
  copy.deep_merge!(other_hash, &block)
9
9
  end
@@ -18,11 +18,28 @@ module Hashie
18
18
 
19
19
  private
20
20
 
21
+ def _deep_dup(hash)
22
+ copy = hash.dup
23
+
24
+ copy.each do |key, value|
25
+ copy[key] =
26
+ if value.is_a?(::Hash)
27
+ _deep_dup(value)
28
+ else
29
+ Hashie::Utils.safe_dup(value)
30
+ end
31
+ end
32
+
33
+ copy
34
+ end
35
+
21
36
  def _recursive_merge(hash, other_hash, &block)
22
37
  other_hash.each do |k, v|
23
38
  hash[k] =
24
39
  if hash.key?(k) && hash[k].is_a?(::Hash) && v.is_a?(::Hash)
25
40
  _recursive_merge(hash[k], v, &block)
41
+ elsif v.is_a?(::Hash)
42
+ _recursive_merge({}, v, &block)
26
43
  elsif hash.key?(k) && block_given?
27
44
  yield(k, hash[k], v)
28
45
  else
@@ -0,0 +1,61 @@
1
+ module Hashie
2
+ module Extensions
3
+ module Mash
4
+ # Allow a Mash to properly respond to everything
5
+ #
6
+ # By default, Mashes only say they respond to methods for keys that exist
7
+ # in their key set or any of the affix methods (e.g. setter, underbang,
8
+ # etc.). This causes issues when you try to use them within a
9
+ # SimpleDelegator or bind to a method for a key that is unset.
10
+ #
11
+ # This extension allows a Mash to properly respond to `respond_to?` and
12
+ # `method` for keys that have not yet been set. This enables full
13
+ # compatibility with SimpleDelegator and thunk-oriented programming.
14
+ #
15
+ # There is a trade-off with this extension: it will run slower than a
16
+ # regular Mash; insertions and initializations with keys run approximately
17
+ # 20% slower and cost approximately 19KB of memory per class that you
18
+ # make permissive.
19
+ #
20
+ # @api public
21
+ # @example Make a new, permissively responding Mash subclass
22
+ # class PermissiveMash < Hashie::Mash
23
+ # include Hashie::Extensions::Mash::PermissiveRespondTo
24
+ # end
25
+ #
26
+ # mash = PermissiveMash.new(a: 1)
27
+ # mash.respond_to? :b #=> true
28
+ module PermissiveRespondTo
29
+ # The Ruby hook for behavior when including the module
30
+ #
31
+ # @api private
32
+ # @private
33
+ # @return void
34
+ def self.included(base)
35
+ base.instance_variable_set :@_method_cache, base.instance_methods
36
+ base.define_singleton_method(:method_cache) { @_method_cache }
37
+ end
38
+
39
+ # The Ruby hook for determining what messages a class might respond to
40
+ #
41
+ # @api private
42
+ # @private
43
+ def respond_to_missing?(_method_name, _include_private = false)
44
+ true
45
+ end
46
+
47
+ private
48
+
49
+ # Override the Mash logging behavior to account for permissiveness
50
+ #
51
+ # @api private
52
+ # @private
53
+ def log_collision?(method_key)
54
+ self.class.method_cache.include?(method_key) &&
55
+ !self.class.disable_warnings?(method_key) &&
56
+ !(regular_key?(method_key) || regular_key?(method_key.to_s))
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -18,13 +18,30 @@ module Hashie
18
18
  permitted_classes = @options.fetch(:permitted_classes) { [] }
19
19
  permitted_symbols = @options.fetch(:permitted_symbols) { [] }
20
20
  aliases = @options.fetch(:aliases) { true }
21
- # TODO: Psych in newer rubies expects these args to be keyword args.
22
- YAML.safe_load template.result, permitted_classes, permitted_symbols, aliases
21
+
22
+ yaml_safe_load(template, permitted_classes, permitted_symbols, aliases)
23
23
  end
24
24
 
25
25
  def self.perform(file_path, options = {})
26
26
  new(file_path, options).perform
27
27
  end
28
+
29
+ private
30
+
31
+ if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0') # Ruby 2.6+
32
+ def yaml_safe_load(template, permitted_classes, permitted_symbols, aliases)
33
+ YAML.safe_load(
34
+ template.result,
35
+ permitted_classes: permitted_classes,
36
+ permitted_symbols: permitted_symbols,
37
+ aliases: aliases
38
+ )
39
+ end
40
+ else
41
+ def yaml_safe_load(template, permitted_classes, permitted_symbols, aliases)
42
+ YAML.safe_load(template.result, permitted_classes, permitted_symbols, aliases)
43
+ end
44
+ end
28
45
  end
29
46
  end
30
47
  end
@@ -9,7 +9,11 @@ module Hashie
9
9
 
10
10
  module ClassMethods
11
11
  def with_minimum_ruby(version)
12
- yield if RubyVersion.new(RUBY_VERSION) >= RubyVersion.new(version)
12
+ yield if with_minimum_ruby?(version)
13
+ end
14
+
15
+ def with_minimum_ruby?(version)
16
+ RubyVersion.new(RUBY_VERSION) >= RubyVersion.new(version)
13
17
  end
14
18
  end
15
19
  end
@@ -16,7 +16,8 @@ module Hashie
16
16
  #
17
17
  # * No punctuation: Returns the value of the hash for that key, or nil if none exists.
18
18
  # * Assignment (<tt>=</tt>): Sets the attribute of the given method name.
19
- # * Existence (<tt>?</tt>): Returns true or false depending on whether that key has been set.
19
+ # * Truthiness (<tt>?</tt>): Returns true or false depending on the truthiness of
20
+ # the attribute, or false if the key is not set.
20
21
  # * Bang (<tt>!</tt>): Forces the existence of this key, used for deep Mashes. Think of it
21
22
  # as "touch" for mashes.
22
23
  # * Under Bang (<tt>_</tt>): Like Bang, but returns a new Mash rather than creating a key.
@@ -73,8 +74,9 @@ module Hashie
73
74
  return @_mashes[path] if @_mashes.key?(path)
74
75
  raise ArgumentError, "The following file doesn't exist: #{path}" unless File.file?(path)
75
76
 
76
- parser = options.fetch(:parser) { Hashie::Extensions::Parsers::YamlErbParser }
77
- @_mashes[path] = new(parser.perform(path, options.except(:parser))).freeze
77
+ options = options.dup
78
+ parser = options.delete(:parser) { Hashie::Extensions::Parsers::YamlErbParser }
79
+ @_mashes[path] = new(parser.perform(path, options)).freeze
78
80
  end
79
81
 
80
82
  def to_module(mash_method_name = :settings)
@@ -172,12 +174,6 @@ module Hashie
172
174
  super(*keys.map { |key| convert_key(key) })
173
175
  end
174
176
 
175
- # Returns a new instance of the class it was called on, with nil values
176
- # removed.
177
- def compact
178
- self.class.new(super)
179
- end
180
-
181
177
  # Returns a new instance of the class it was called on, using its keys as
182
178
  # values, and its values as keys. The new values and keys will always be
183
179
  # strings.
@@ -211,20 +207,7 @@ module Hashie
211
207
  alias include? key?
212
208
  alias member? key?
213
209
 
214
- # Performs a deep_update on a duplicate of the
215
- # current mash.
216
- def deep_merge(other_hash, &blk)
217
- dup.deep_update(other_hash, &blk)
218
- end
219
-
220
- # Recursively merges this mash with the passed
221
- # in hash, merging each hash in the hierarchy.
222
- def deep_update(other_hash, &blk)
223
- _deep_update(other_hash, &blk)
224
- self
225
- end
226
-
227
- with_minimum_ruby('2.6.0') do
210
+ if with_minimum_ruby?('2.6.0')
228
211
  # Performs a deep_update on a duplicate of the
229
212
  # current mash.
230
213
  def deep_merge(*other_hashes, &blk)
@@ -239,6 +222,19 @@ module Hashie
239
222
  end
240
223
  self
241
224
  end
225
+ else
226
+ # Performs a deep_update on a duplicate of the
227
+ # current mash.
228
+ def deep_merge(other_hash, &blk)
229
+ dup.deep_update(other_hash, &blk)
230
+ end
231
+
232
+ # Recursively merges this mash with the passed
233
+ # in hash, merging each hash in the hierarchy.
234
+ def deep_update(other_hash, &blk)
235
+ _deep_update(other_hash, &blk)
236
+ self
237
+ end
242
238
  end
243
239
 
244
240
  # Alias these lexically so they get the correctly defined
@@ -339,6 +335,12 @@ module Hashie
339
335
  def transform_values(&blk)
340
336
  self.class.new(super(&blk))
341
337
  end
338
+
339
+ # Returns a new instance of the class it was called on, with nil values
340
+ # removed.
341
+ def compact
342
+ self.class.new(super)
343
+ end
342
344
  end
343
345
 
344
346
  with_minimum_ruby('2.5.0') do
@@ -381,8 +383,6 @@ module Hashie
381
383
  when ::Hash
382
384
  val = val.dup if duping
383
385
  self.class.new(val)
384
- when Array
385
- val.map { |e| convert_value(e) }
386
386
  when ::Array
387
387
  Array.new(val.map { |e| convert_value(e) })
388
388
  else
@@ -406,7 +406,12 @@ module Hashie
406
406
  end
407
407
 
408
408
  def log_collision?(method_key)
409
- respond_to?(method_key) && !self.class.disable_warnings?(method_key) &&
409
+ return unless respond_to?(method_key)
410
+
411
+ _, suffix = method_name_and_suffix(method_key)
412
+
413
+ (!suffix || suffix == '='.freeze) &&
414
+ !self.class.disable_warnings?(method_key) &&
410
415
  !(regular_key?(method_key) || regular_key?(method_key.to_s))
411
416
  end
412
417
  end