class ROM::SQL::TypeSerializer

@api private

Public Class Methods

[](db_type) click to toggle source
# File lib/rom/sql/type_serializer.rb, line 17
def self.[](db_type)
  registry[db_type]
end
register(db_type, builder) click to toggle source
# File lib/rom/sql/type_serializer.rb, line 13
def self.register(db_type, builder)
  registry[db_type] = builder
end

Public Instance Methods

call(type) { |type| ... } click to toggle source
# File lib/rom/sql/type_serializer.rb, line 35
def call(type)
  return type.meta[:db_type] if type.meta[:db_type]

  meta = type.meta[:read] ? { read: type.meta[:read] } : EMPTY_HASH

  self.class.mapping.fetch(type.with(meta: meta)) {
    if block_given?
      yield(type)
    end or raise "Cannot serialize #{ type }"
  }
end