Module: BitBucket::ParameterFilter
- Included in:
- API
- Defined in:
- lib/bitbucket_rest_api/parameter_filter.rb
Overview
Allows you to specify parameters keys which will be preserved in parameters hash and its subhashes. Any keys from the nested hash that do not match will be removed.
Instance Method Summary collapse
-
#filter!(keys, params, options = { recursive: true }) ⇒ Object
Removes any keys from nested hashes that don’t match predefiend keys.
Instance Method Details
#filter!(keys, params, options = { recursive: true }) ⇒ Object
Removes any keys from nested hashes that don’t match predefiend keys
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/bitbucket_rest_api/parameter_filter.rb', line 9 def filter!(keys, params, = { recursive: true }) # :nodoc: case params when Hash params.keys.each do |k, _v| if keys.include?(k) || BitBucket::Validations::VALID_API_KEYS.include?(k) filter!(keys, params[k]) if [:recursive] else params.delete(k) end end when Array params.map! do |el| filter!(keys, el) if [:recursive] end else params end params end |