Support ruby2.5 Hash#slice to Sinatra::IndifferentHash

This commit is contained in:
Shota Iguchi 2018-02-23 01:56:39 +09:00
parent 6c1ed0b393
commit c006e58c0a
1 changed files with 5 additions and 0 deletions

View File

@ -104,6 +104,11 @@ module Sinatra
super(*keys.map(&method(:convert_key)))
end if method_defined?(:fetch_values) # Added in Ruby 2.3
def slice(*keys)
keys.map!(&method(:convert_key))
self.class[super(*keys)]
end if method_defined?(:slice) # Added in Ruby 2.5
def values_at(*keys)
super(*keys.map(&method(:convert_key)))
end