Class: KDomain::Schemas::Domain::Model::Column

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/k_domain/schemas/domain.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#relationshipsObject

Any column may have a bunch of related models using various relationship types (belong_to, has_one, has_many etc…)



31
32
33
# File 'lib/k_domain/schemas/domain.rb', line 31

def relationships
  @relationships
end

Instance Method Details

#csharp_typeObject



45
46
47
48
49
# File 'lib/k_domain/schemas/domain.rb', line 45

def csharp_type
  return @csharp_type if defined? @csharp_type

  @csharp_type = KDomain::Schemas::CSHARP_TYPE[type] || '******'
end

#db_typeObject



33
34
35
36
37
# File 'lib/k_domain/schemas/domain.rb', line 33

def db_type
  return @db_type if defined? @db_type

  @db_type = KDomain::Schemas::DB_TYPE[type] || '******'
end

#ruby_typeObject



39
40
41
42
43
# File 'lib/k_domain/schemas/domain.rb', line 39

def ruby_type
  return @ruby_type if defined? @ruby_type

  @ruby_type = KDomain::Schemas::RUBY_TYPE[type] || '******'
end

#to_hObject

rubocop:disable Metrics/AbcSize



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/k_domain/schemas/domain.rb', line 52

def to_h
  {
    name: name,
    name_plural: name_plural,
    type: type,
    precision: precision,
    scale: scale,
    default: default,
    default_as_code: value_as_code(default),
    null: null,
    null_as_code: value_as_code(null), # handlebars does not like null property name
    limit: limit,
    array: array,
    array_as_code: value_as_code(array),
    db_type: db_type,
    ruby_type: ruby_type,
    csharp_type: csharp_type,
    structure_type: structure_type,
    relationships: relationships
  }
end