Class: Intercept::Strategy::Mapper
- Inherits:
-
Object
- Object
- Intercept::Strategy::Mapper
- Defined in:
- lib/intercept/strategy/mapper.rb
Instance Attribute Summary collapse
-
#bucket_map ⇒ Object
readonly
Returns the value of attribute bucket_map.
-
#fallback_strategy ⇒ Object
readonly
Returns the value of attribute fallback_strategy.
Instance Method Summary collapse
-
#initialize(bucket_map, fallback_strategy = nil) ⇒ Mapper
constructor
A new instance of Mapper.
- #process(value) ⇒ Object
Constructor Details
#initialize(bucket_map, fallback_strategy = nil) ⇒ Mapper
8 9 10 11 |
# File 'lib/intercept/strategy/mapper.rb', line 8 def initialize(bucket_map, fallback_strategy = nil) @bucket_map = parse_bucket_map bucket_map @fallback_strategy = fallback_strategy end |
Instance Attribute Details
#bucket_map ⇒ Object (readonly)
Returns the value of attribute bucket_map.
6 7 8 |
# File 'lib/intercept/strategy/mapper.rb', line 6 def bucket_map @bucket_map end |
#fallback_strategy ⇒ Object (readonly)
Returns the value of attribute fallback_strategy.
6 7 8 |
# File 'lib/intercept/strategy/mapper.rb', line 6 def fallback_strategy @fallback_strategy end |
Instance Method Details
#process(value) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/intercept/strategy/mapper.rb', line 13 def process(value) return value if value.nil? || value.empty? mapped_value = map_value(value) if fallback_strategy && mapped_value.empty? fallback_strategy.process(value) else mapped_value end end |