Module: ClickHouse::Extend::TypeDefinition

Included in:
ClickHouse
Defined in:
lib/click_house/extend/type_definition.rb

Constant Summary collapse

NULLABLE =
'Nullable'
NULLABLE_RE =
/#{NULLABLE}/i.freeze

Instance Method Summary collapse

Instance Method Details

#add_type(type, klass, nullable: true) ⇒ Object


13
14
15
16
# File 'lib/click_house/extend/type_definition.rb', line 13

def add_type(type, klass, nullable: true)
  types[type] = klass
  types["#{NULLABLE}(#{type})"] = Type::NullableType.new(klass) if nullable
end

#type_names(nullable:) ⇒ Enum<String>

Returns:

  • (Enum<String>)

19
20
21
# File 'lib/click_house/extend/type_definition.rb', line 19

def type_names(nullable:)
  nullable ? types.keys : types.keys.grep_v(NULLABLE_RE)
end

#typesObject


9
10
11
# File 'lib/click_house/extend/type_definition.rb', line 9

def types
  @types ||= Hash.new(Type::UndefinedType.new)
end