class ActiveRecord::Type::Spanner::SpannerActiveRecordConverter

Public Class Methods

convert_active_model_type_to_spanner(type) click to toggle source

Converts an ActiveModel::Type to a Spanner type code.

# File lib/active_record/type/spanner/spanner_active_record_converter.rb, line 15
def self.convert_active_model_type_to_spanner type # rubocop:disable Metrics/CyclomaticComplexity
  case type
  when NilClass then nil
  when ActiveModel::Type::Integer, ActiveModel::Type::BigInteger then :INT64
  when ActiveModel::Type::Boolean then :BOOL
  when ActiveModel::Type::String, ActiveModel::Type::ImmutableString then :STRING
  when ActiveModel::Type::Binary, ActiveRecord::Type::Spanner::Bytes then :BYTES
  when ActiveModel::Type::Float then :FLOAT64
  when ActiveModel::Type::Decimal then :NUMERIC
  when ActiveModel::Type::DateTime, ActiveModel::Type::Time, ActiveRecord::Type::Spanner::Time then :TIMESTAMP
  when ActiveModel::Type::Date then :DATE
  when ActiveRecord::Type::Json then :JSON
  when ActiveRecord::Type::Spanner::Array then [convert_active_model_type_to_spanner(type.element_type)]
  end
end