class Rack::ApplyFilter
Attributes
filter[R]
request[R]
Public Class Methods
new(filter, request)
click to toggle source
# File lib/rack/filter_param/apply_filter.rb, line 5 def initialize(filter, request) @filter = filter @request = request end
Public Instance Methods
call()
click to toggle source
# File lib/rack/filter_param/apply_filter.rb, line 10 def call return unless param_exists? return unless path_matches? return unless if_proc_affirmative? if delete_from_action_dispatch || delete_from_request filtered_params << [ param, nil ] end end
Private Instance Methods
action_dispatch_params()
click to toggle source
# File lib/rack/filter_param/apply_filter.rb, line 38 def action_dispatch_params env[FilterParam::ACTION_DISPATCH_KEY] end
action_dispatch_parsed?()
click to toggle source
# File lib/rack/filter_param/apply_filter.rb, line 42 def action_dispatch_parsed? !action_dispatch_params.nil? end
delete_from_action_dispatch()
click to toggle source
# File lib/rack/filter_param/apply_filter.rb, line 61 def delete_from_action_dispatch action_dispatch_parsed? && !!action_dispatch_params.delete(param) end
delete_from_request()
click to toggle source
# File lib/rack/filter_param/apply_filter.rb, line 65 def delete_from_request !!request.delete_param(param) end
filtered_params()
click to toggle source
# File lib/rack/filter_param/apply_filter.rb, line 69 def filtered_params env[FilterParam::FILTERED_PARAMS_KEY] ||= [] end
if_proc_affirmative?()
click to toggle source
# File lib/rack/filter_param/apply_filter.rb, line 55 def if_proc_affirmative? return true if if_proc.nil? if_proc.call(param_value) end
param_exists?()
click to toggle source
# File lib/rack/filter_param/apply_filter.rb, line 30 def param_exists? params.has_key?(param) end
param_value()
click to toggle source
# File lib/rack/filter_param/apply_filter.rb, line 34 def param_value params[param] end
params()
click to toggle source
# File lib/rack/filter_param/apply_filter.rb, line 26 def params action_dispatch_parsed? ? action_dispatch_params : request.params end
path_matches?()
click to toggle source
# File lib/rack/filter_param/apply_filter.rb, line 46 def path_matches? return true if path.nil? return env['PATH_INFO'] == path if path.is_a?(String) return env['PATH_INFO'] =~ path if path.is_a?(Regexp) false end