summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBobby McDonald <BobbyMcWho@users.noreply.github.com>2019-10-02 10:48:19 -0400
committerDaniel Doubrovkine (dB.) @dblockdotorg <dblock@dblock.org>2019-10-02 10:48:19 -0400
commitca3604516b5725b30a290482c219ca55fca5de49 (patch)
treed8c190ab769cba11a430c5c4b92162547f305fde /lib
parent04cd30af1362574a1adea53aae0008e5732ea994 (diff)
downloadhashie-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.rb14
-rw-r--r--lib/hashie/railtie.rb7
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