Parent

Class Index [+]

Quicksearch

ActionDispatch::Http::ParameterFilter

Constants

FILTERED

Public Class Methods

new(filters) click to toggle source
   # File lib/action_dispatch/http/parameter_filter.rb, line 5
5:       def initialize(filters)
6:         @filters = filters
7:       end

Public Instance Methods

filter(params) click to toggle source
    # File lib/action_dispatch/http/parameter_filter.rb, line 9
 9:       def filter(params)
10:         if enabled?
11:           compiled_filter.call(params)
12:         else
13:           params.dup
14:         end
15:       end

Private Instance Methods

compile_filter() click to toggle source
    # File lib/action_dispatch/http/parameter_filter.rb, line 53
53:       def compile_filter
54:         strings, regexps, blocks = [], [], []
55: 
56:         @filters.each do |item|
57:           case item
58:           when NilClass
59:           when Proc
60:             blocks << item
61:           when Regexp
62:             regexps << item
63:           else
64:             strings << item.to_s
65:           end
66:         end
67: 
68:         regexps << Regexp.new(strings.join('|'), true) unless strings.empty?
69:         [regexps, blocks]
70:       end
compiled_filter() click to toggle source
    # File lib/action_dispatch/http/parameter_filter.rb, line 25
25:       def compiled_filter
26:         @compiled_filter ||= begin
27:           regexps, blocks = compile_filter
28: 
29:           lambda do |original_params|
30:             filtered_params = {}
31: 
32:             original_params.each do |key, value|
33:               if regexps.find { |r| key =~ r }
34:                 value = FILTERED
35:               elsif value.is_a?(Hash)
36:                 value = filter(value)
37:               elsif value.is_a?(Array)
38:                 value = value.map { |v| v.is_a?(Hash) ? filter(v) : v }
39:               elsif blocks.present?
40:                 key = key.dup
41:                 value = value.dup if value.duplicable?
42:                 blocks.each { |b| b.call(key, value) }
43:               end
44: 
45:               filtered_params[key] = value
46:             end
47: 
48:             filtered_params
49:           end
50:         end
51:       end
enabled?() click to toggle source
    # File lib/action_dispatch/http/parameter_filter.rb, line 19
19:       def enabled?
20:         @filters.present?
21:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.