diff options
| author | Bobby McDonald <BobbyMcWho@users.noreply.github.com> | 2019-10-02 10:48:19 -0400 |
|---|---|---|
| committer | Daniel Doubrovkine (dB.) @dblockdotorg <dblock@dblock.org> | 2019-10-02 10:48:19 -0400 |
| commit | ca3604516b5725b30a290482c219ca55fca5de49 (patch) | |
| tree | d8c190ab769cba11a430c5c4b92162547f305fde /lib | |
| parent | 04cd30af1362574a1adea53aae0008e5732ea994 (diff) | |
| download | hashie-ca3604516b5725b30a290482c219ca55fca5de49.tar.gz | |
Make Hashie play nice with Rails 6 Hash#except method (#479)
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/hashie/extensions/active_support/core_ext/hash.rb | 14 | ||||
| -rw-r--r-- | lib/hashie/railtie.rb | 7 |
2 files changed, 21 insertions, 0 deletions
diff --git a/lib/hashie/extensions/active_support/core_ext/hash.rb b/lib/hashie/extensions/active_support/core_ext/hash.rb new file mode 100644 index 0000000..b8d71f7 --- /dev/null +++ b/lib/hashie/extensions/active_support/core_ext/hash.rb @@ -0,0 +1,14 @@ +module Hashie + module Extensions + module ActiveSupport + module CoreExt + module Hash + def except(*keys) + string_keys = keys.map { |key| convert_key(key) } + super(*string_keys) + end + end + end + end + end +end diff --git a/lib/hashie/railtie.rb b/lib/hashie/railtie.rb index 65cd007..c5f05b7 100644 --- a/lib/hashie/railtie.rb +++ b/lib/hashie/railtie.rb @@ -7,6 +7,13 @@ begin initializer 'hashie.configure_logger', after: 'initialize_logger' do Hashie.logger = Rails.logger end + + initializer 'hashie.patch_hash_except', after: 'load_active_support' do + if Rails::VERSION::MAJOR >= 6 + require 'hashie/extensions/active_support/core_ext/hash' + Hashie::Mash.send(:include, Hashie::Extensions::ActiveSupport::CoreExt::Hash) + end + end end end rescue LoadError => e |
