Class: Realize::Value::Map

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#valuesObject (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