Class: Intercept::Strategy::WhiteList

Inherits:
Object
  • Object
show all
Defined in:
lib/intercept/strategy/white_list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(white_list, fallback_strategy = nil) ⇒ WhiteList

Returns a new instance of WhiteList.



8
9
10
11
# 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

Instance Attribute Details

#fallback_strategyObject (readonly)

Returns the value of attribute fallback_strategy.



6
7
8
# File 'lib/intercept/strategy/white_list.rb', line 6

def fallback_strategy
  @fallback_strategy
end

#white_listObject (readonly)

Returns the value of attribute white_list.



6
7
8
# File 'lib/intercept/strategy/white_list.rb', line 6

def white_list
  @white_list
end

Instance Method Details

#process(value) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# 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