1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00

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

View file

@ -104,6 +104,11 @@ module Sinatra
super(*keys.map(&method(:convert_key))) super(*keys.map(&method(:convert_key)))
end if method_defined?(:fetch_values) # Added in Ruby 2.3 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) def values_at(*keys)
super(*keys.map(&method(:convert_key))) super(*keys.map(&method(:convert_key)))
end end