Class: Realize::Value::Map
- Inherits:
-
Object
- Object
- Realize::Value::Map
- Defined in:
- lib/realize/value/map.rb
Overview
This transformer can take in a hash of: “value” -> “new value”. It’s basically a simple way for doing simple if X = Y, then Z replacements. This can be extended to include and customize case and type sensitivies, but right now it is type and case-sensitive so be careful!
Instance Attribute Summary collapse
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
-
#initialize(values: {}) ⇒ Map
constructor
A new instance of Map.
- #transform(_resolver, value, _time, _record) ⇒ Object
Constructor Details
#initialize(values: {}) ⇒ Map
Returns a new instance of Map.
21 22 23 24 25 |
# File 'lib/realize/value/map.rb', line 21 def initialize(values: {}) @values = values || {} freeze end |
Instance Attribute Details
#values ⇒ Object (readonly)
Returns the value of attribute values.
19 20 21 |
# File 'lib/realize/value/map.rb', line 19 def values @values end |
Instance Method Details
#transform(_resolver, value, _time, _record) ⇒ Object
27 28 29 |
# File 'lib/realize/value/map.rb', line 27 def transform(_resolver, value, _time, _record) values.fetch(value, value) end |