class ActiveRecord::Type::Spanner::Array

Attributes

element_type[R]

Public Class Methods

new(element_type) click to toggle source
# File lib/active_record/type/spanner/array.rb, line 14
def initialize element_type
  @element_type = element_type
end

Public Instance Methods

serialize(value) click to toggle source
Calls superclass method
# File lib/active_record/type/spanner/array.rb, line 18
def serialize value
  return super if value.nil?
  return super unless @element_type.is_a? Type::Decimal
  return super unless value.respond_to? :map

  # Convert a decimal (NUMERIC) array to a String array to prevent it from being encoded as a FLOAT64 array.
  value.map do |v|
    next if v.nil?
    v.to_s
  end
end