Class: Parqueteur::TypeResolver

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/parqueteur/type_resolver.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.register_type(type, klass) ⇒ Object



32
33
34
# File 'lib/parqueteur/type_resolver.rb', line 32

def self.register_type(type, klass)
  registered_types[type] = klass
end

.registered_typesObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/parqueteur/type_resolver.rb', line 7

def self.registered_types
  @registered_types ||= {
    array: Parqueteur::Types::ArrayType,
    bigdecimal: Parqueteur::Types::Decimal256Type,
    bigint: Parqueteur::Types::Int64Type,
    boolean: Parqueteur::Types::BooleanType,
    date: Parqueteur::Types::Date32Type,
    date32: Parqueteur::Types::Date32Type,
    date64: Parqueteur::Types::Date64Type,
    decimal: Parqueteur::Types::Decimal128Type,
    decimal128: Parqueteur::Types::Decimal128Type,
    decimal256: Parqueteur::Types::Decimal256Type,
    int32: Parqueteur::Types::Int32Type,
    int64: Parqueteur::Types::Int64Type,
    integer: Parqueteur::Types::Int32Type,
    map: Parqueteur::Types::MapType,
    string: Parqueteur::Types::StringType,
    struct: Parqueteur::Types::StructType,
    time: Parqueteur::Types::Time32Type,
    time32: Parqueteur::Types::Time32Type,
    time64: Parqueteur::Types::Time64Type,
    timestamp: Parqueteur::Types::TimestampType
  }
end

.resolve(*args, &block) ⇒ Object



36
37
38
# File 'lib/parqueteur/type_resolver.rb', line 36

def self.resolve(*args, &block)
  instance.resolve(*args, &block)
end

Instance Method Details

#resolve(type, options = {}, &block) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/parqueteur/type_resolver.rb', line 40

def resolve(type, options = {}, &block)
  if type.is_a?(Symbol)
    resolve_from_symbol(type, options, &block)
  else
    type.new(options, &block)
  end
end