class Intercept::Strategy::WhiteList
Attributes
fallback_strategy[R]
white_list[R]
Public Class Methods
new(white_list, fallback_strategy = nil)
click to toggle source
# File lib/intercept/strategy/white_list.rb, line 8 def initialize(white_list, fallback_strategy = nil) @white_list = parse_white_list white_list @fallback_strategy = fallback_strategy end
Public Instance Methods
process(value)
click to toggle source
# File lib/intercept/strategy/white_list.rb, line 13 def process(value) return value if value.nil? || value.empty? white_listed_value = white_list_value(value) if fallback_strategy && white_listed_value.empty? fallback_strategy.process(value) else white_listed_value end end
Private Instance Methods
parse_white_list(white_list)
click to toggle source
# File lib/intercept/strategy/white_list.rb, line 27 def parse_white_list(white_list) if white_list.respond_to?(:call) white_list else raise '@param white_list must respond to #call' end end
white_list_value(value)
click to toggle source
# File lib/intercept/strategy/white_list.rb, line 35 def white_list_value(value) value.select do |unit| white_list.call.find do |regex| regex.match?(unit) end end.compact.uniq end