Class: Intercept::Strategy::WhiteList
- Inherits:
-
Object
- Object
- Intercept::Strategy::WhiteList
- Defined in:
- lib/intercept/strategy/white_list.rb
Instance Attribute Summary collapse
-
#fallback_strategy ⇒ Object
readonly
Returns the value of attribute fallback_strategy.
-
#white_list ⇒ Object
readonly
Returns the value of attribute white_list.
Instance Method Summary collapse
-
#initialize(white_list, fallback_strategy = nil) ⇒ WhiteList
constructor
A new instance of WhiteList.
- #process(value) ⇒ Object
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_strategy ⇒ Object (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_list ⇒ Object (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 |