Class: ROM::SQL::TypeSerializer Private

Inherits:
Object
  • Object
show all
Extended by:
Dry::Core::ClassAttributes
Defined in:
lib/rom/sql/type_serializer.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

API:

  • private

Direct Known Subclasses

Postgres::TypeSerializer

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.[](db_type) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



15
16
17
# File 'lib/rom/sql/type_serializer.rb', line 15

def self.[](db_type)
  registry[db_type]
end

.register(db_type, builder) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



11
12
13
# File 'lib/rom/sql/type_serializer.rb', line 11

def self.register(db_type, builder)
  registry[db_type] = builder
end

Instance Method Details

#call(type) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/rom/sql/type_serializer.rb', line 33

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