Parent

Class Index [+]

Quicksearch

ActionDispatch::Http::ParameterFilter

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