class Realize::Type::Array

Ensure the value is an array by calling Kernel#Array on the value. If the value is a hash then it will ensure the hash data structure is preserved and placed within the array. Normally calling Array(hash) would yield an array of key-value pair arrays. For our pipeline we generally treat hashes as “record-like” objects, so we need to ensure we keep it in tact.

This does not mean other data types do not suffer from Kernel#Array converting it to something unexpected. For example, passing in a Time object would yield an array of parts:

Array(Time.now) => [2, 59, 10, 21, 11, 2020, 6, 326, false, "CST"]

See: ruby-doc.org/core-2.7.2/Kernel.html#method-i-Array for more information.

Public Instance Methods

transform(_resolver, value, _time, _record) click to toggle source
# File lib/realize/type/array.rb, line 29
def transform(_resolver, value, _time, _record)
  return nil if nullable && value.nil?

  array(value)
end