module Rack::Reducer::Refinements

Refine a few core classes in Rack::Reducer's scope only

Public Instance Methods

all_argument_names() click to toggle source
# File lib/rack/reducer/refinements.rb, line 12
def all_argument_names
  parameters.map(&:last)
end
deep_symbolize_keys() click to toggle source
# File lib/rack/reducer/refinements.rb, line 32
def deep_symbolize_keys
  each_with_object({}) do |(key, val), hash|
    hash[key.to_sym] = val.is_a?(Hash) ? val.deep_symbolize_keys : val
  end
end
empty?() click to toggle source
# File lib/rack/reducer/refinements.rb, line 42
def empty?
  true
end
required_argument_names() click to toggle source
# File lib/rack/reducer/refinements.rb, line 8
def required_argument_names
  parameters.select { |type, _| type == :keyreq }.map(&:last)
end
satisfies?(params) click to toggle source
# File lib/rack/reducer/refinements.rb, line 16
def satisfies?(params)
  keywords = required_argument_names
  params.slice(*keywords).keys.to_set == keywords.to_set
end
slice(*keys) click to toggle source
# File lib/rack/reducer/refinements.rb, line 25
def slice(*keys)
  [keys, values_at(*keys)].transpose.select { |_k, val| val }.to_h
end