I’d like to use something like
hash.pick('prop1', 'prop2')
the same way as using underscores pick method ( takes properties of an object/hash and create a new hash based on them )
So it will look like this
{ prop1: 'asdf', prop2: 'qwer', prop3: 'uiop' }.pick( 'prop2', 'prop3' )
# equals { prop2: 'qwer', prop3: 'uiop' }
For Ruby 2.5 and later, use the built-in hash.slice method.
This method was first introduced in Rails (ActiveSupport), so it was usable in earlier Ruby versions within Rails environment.