diff options
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 |
