lib/sequel_rails.rb in sequel-rails-0.9.11 vs lib/sequel_rails.rb in sequel-rails-0.9.12

- old
+ new

@@ -4,6 +4,29 @@ module SequelRails def self.jruby? (defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby') || defined?(JRUBY_VERSION) end + + if Hash.public_instance_methods.include? :deep_symbolize_keys + def self.deep_symbolize_keys(hash) + hash.deep_symbolize_keys + end + else + def self.deep_symbolize_keys(hash) + h = {} + hash.each { |key, value| h[key.to_sym] = deep_symbolize_keys_map(value) } + h + end + + def self.deep_symbolize_keys_map(value) + case value + when Hash + deep_symbolize_keys(value) + when Array + value.map { |v| deep_symbolize_keys_map(v) } + else + value + end + end + end end