Class: KDomain::DomainModel::ColumnOld

Inherits:
Object
  • Object
show all
Defined in:
lib/k_domain/schemas/domain/old/column_old.rb

Constant Summary collapse

RUBY_TYPE =

DONE

{
  string: 'String',
  text: 'String',
  primary_key: 'Integer', # this could be GUID in future
  foreign_key: 'Integer', # this could be GUID in future
  integer: 'Integer',
  boolean: 'Boolean',
  float: 'Float',
  decimal: 'Decimal',
  datetime: 'DateTime',
  date: 'DateTime',
  json: 'Hash',
  jsonb: 'Hash',
  hstore: 'Hash'
}.freeze
CSHARP_TYPE =

DONE

{
  string: 'string',
  text: 'string', # NEED TO DEAL WITH THIS BETTER
  integer: 'int',
  boolean: 'bool',
  decimal: 'decimal',
  float: 'double',
  datetime: 'DateTime',
  date: 'DateTime',
  json: 'object',
  jsonb: 'object',
  hstore: 'object'
}.freeze
DB_TYPE =

this is used by the ruby migration files DONE

{
  boolean: 'boolean',
  primary_key: 'integer',
  foreign_key: 'integer',
  integer: 'integer',
  decimal: 'decimal',
  float: 'float',
  datetime: 'datetime',
  date: 'date',
  text: 'text',
  string: 'string',
  json: 'json',
  jsonb: 'jsonb',
  hstore: 'hstore'
}.freeze
SIMPLE_ATTRIBS =
%i[
  name
  name_plural
  type
  structure_type
  foreign_key?
  foreign_table
  foreign_id
].freeze
DETAILED_ATTRIBS =
SIMPLE_ATTRIBS + %i[
  title
  required
  reference_type
  db_type
  ruby_type
  csharp_type
  format_type
  description
  belongs_to
]
EXTRA_ATTRIBS =
DETAILED_ATTRIBS + %i[
  precision
  scale
  default
  null
  limit
  array
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#arrayObject

Returns the value of attribute array.



125
126
127
# File 'lib/k_domain/schemas/domain/old/column_old.rb', line 125

def array
  @array
end

#belongs_toObject

Returns the value of attribute belongs_to.



113
114
115
# File 'lib/k_domain/schemas/domain/old/column_old.rb', line 113

def belongs_to
  @belongs_to
end

#defaultObject

Returns the value of attribute default.



121
122
123
# File 'lib/k_domain/schemas/domain/old/column_old.rb', line 121

def default
  @default
end

#descriptionObject

Returns the value of attribute description.



108
109
110
# File 'lib/k_domain/schemas/domain/old/column_old.rb', line 108

def description
  @description
end

#foreign_idObject Also known as: reference_table

this may not always be accurate, should support override



115
116
117
# File 'lib/k_domain/schemas/domain/old/column_old.rb', line 115

def foreign_id
  @foreign_id
end

#foreign_keyObject Also known as: foreign_key?

Returns the value of attribute foreign_key.



110
111
112
# File 'lib/k_domain/schemas/domain/old/column_old.rb', line 110

def foreign_key
  @foreign_key
end

#foreign_tableObject

Returns the value of attribute foreign_table.



112
113
114
# File 'lib/k_domain/schemas/domain/old/column_old.rb', line 112

def foreign_table
  @foreign_table
end

#format_typeObject

‘references’ if foreign key, ‘primary_key’ if primary key, will map_from_type(type)) | attr_accessor :db_type



107
108
109
# File 'lib/k_domain/schemas/domain/old/column_old.rb', line 107

def format_type
  @format_type
end

#limitObject

Returns the value of attribute limit.



124
125
126
# File 'lib/k_domain/schemas/domain/old/column_old.rb', line 124

def limit
  @limit
end

#nameObject

Name of the column



88
89
90
# File 'lib/k_domain/schemas/domain/old/column_old.rb', line 88

def name
  @name
end

#name_pluralObject

Name of the column in plural form



91
92
93
# File 'lib/k_domain/schemas/domain/old/column_old.rb', line 91

def name_plural
  @name_plural
end

#nullObject Also known as: nullable

Returns the value of attribute null.



122
123
124
# File 'lib/k_domain/schemas/domain/old/column_old.rb', line 122

def null
  @null
end

#precisionObject

Extra DB attributes



119
120
121
# File 'lib/k_domain/schemas/domain/old/column_old.rb', line 119

def precision
  @precision
end

#reference_typeObject

Returns the value of attribute reference_type.



102
103
104
# File 'lib/k_domain/schemas/domain/old/column_old.rb', line 102

def reference_type
  @reference_type
end

#requiredObject

true



99
100
101
# File 'lib/k_domain/schemas/domain/old/column_old.rb', line 99

def required
  @required
end

#scaleObject

Returns the value of attribute scale.



120
121
122
# File 'lib/k_domain/schemas/domain/old/column_old.rb', line 120

def scale
  @scale
end

#structure_typeObject

:data, :foreign_key, :timestamp



101
102
103
# File 'lib/k_domain/schemas/domain/old/column_old.rb', line 101

def structure_type
  @structure_type
end

#titleObject

Human readable title



96
97
98
# File 'lib/k_domain/schemas/domain/old/column_old.rb', line 96

def title
  @title
end

#typeObject

Returns the value of attribute type.



93
94
95
# File 'lib/k_domain/schemas/domain/old/column_old.rb', line 93

def type
  @type
end

Instance Method Details

#csharp_typeObject

DONE



158
159
160
161
162
# File 'lib/k_domain/schemas/domain/old/column_old.rb', line 158

def csharp_type
  return @csharp_type if defined? @csharp_type

  @csharp_type = CSHARP_TYPE[type] || '******'
end

#db_typeObject

DONE



144
145
146
147
148
# File 'lib/k_domain/schemas/domain/old/column_old.rb', line 144

def db_type
  return @db_type if defined? @db_type

  @db_type = DB_TYPE[type] || '******'
end

#debug(*flags) ⇒ Object



164
165
166
167
168
# File 'lib/k_domain/schemas/domain/old/column_old.rb', line 164

def debug(*flags)
  debug_simple    if flags.include?(:simple)
  debug_detailed  if flags.include?(:detailed)
  debug_extra     if flags.include?(:extra)
end

#format_arrayObject



139
140
141
# File 'lib/k_domain/schemas/domain/old/column_old.rb', line 139

def format_array
  array.nil? ? '' : array.to_s
end

#format_defaultObject



127
128
129
130
131
132
133
# File 'lib/k_domain/schemas/domain/old/column_old.rb', line 127

def format_default
  return '' if default.nil?
  return "\"#{default}\"" if default.is_a?(String)

  #  || default.is_a?(Symbol)
  default.to_s
end

#format_nullObject



135
136
137
# File 'lib/k_domain/schemas/domain/old/column_old.rb', line 135

def format_null
  null.nil? ? '' : null.to_s
end

#ruby_typeObject

DONE



151
152
153
154
155
# File 'lib/k_domain/schemas/domain/old/column_old.rb', line 151

def ruby_type
  return @ruby_type if defined? @ruby_type

  @ruby_type = RUBY_TYPE[type] || '******'
end