Sha256: 31328f50d47c7b896ef252f1b3fca8ae4d98cb6cad20c978a516aa101612e6b9
Contents?: true
Size: 776 Bytes
Versions: 1
Compression:
Stored size: 776 Bytes
Contents
module Rack module Reducer # refine Proc and hash in this scope only module Refinements refine Proc do def required_argument_names parameters.select { |type, _| type == :keyreq }.map(&:last) end def all_argument_names parameters.map(&:last) end def satisfies?(params) keywords = required_argument_names params.slice(*keywords).keys.to_set == keywords.to_set end end # backport Hash#slice for older rubies unless {}.respond_to?(:slice) refine Hash do def slice(*keys) [keys, values_at(*keys)].transpose.select { |_k, val| val }.to_h end end end end private_constant :Refinements end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rack-reducer-1.0.1 | lib/rack/reducer/refinements.rb |