Class: DBD4::Column

Inherits:
Object
  • Object
show all
Defined in:
lib/dbd4/dbd4_model_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(column, table) ⇒ Column

Returns a new instance of Column.



220
221
222
223
224
225
226
227
228
229
# File 'lib/dbd4/dbd4_model_file.rb', line 220

def initialize(column, table) 
  @id = column.attributes['ID']
  @name= column.attributes['ColName']
  @primary_key = column.attributes['PrimaryKey']
  @foreign_key = column.attributes['IsForeignKey']
  @datatype = Datatype.new(column, self)
  @table = table
  @non_standard_name = false
  @polymorphic = nil
end

Instance Attribute Details

#datatypeObject (readonly)

Returns the value of attribute datatype.



209
210
211
# File 'lib/dbd4/dbd4_model_file.rb', line 209

def datatype
  @datatype
end

#foreign_keyObject (readonly)

Returns the value of attribute foreign_key.



209
210
211
# File 'lib/dbd4/dbd4_model_file.rb', line 209

def foreign_key
  @foreign_key
end

#idObject (readonly)

Returns the value of attribute id.



209
210
211
# File 'lib/dbd4/dbd4_model_file.rb', line 209

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



209
210
211
# File 'lib/dbd4/dbd4_model_file.rb', line 209

def name
  @name
end

#non_standard_nameObject

Returns the value of attribute non_standard_name.



209
210
211
# File 'lib/dbd4/dbd4_model_file.rb', line 209

def non_standard_name
  @non_standard_name
end

#polymorphicObject

Returns the value of attribute polymorphic.



209
210
211
# File 'lib/dbd4/dbd4_model_file.rb', line 209

def polymorphic
  @polymorphic
end

#primary_keyObject (readonly)

Returns the value of attribute primary_key.



209
210
211
# File 'lib/dbd4/dbd4_model_file.rb', line 209

def primary_key
  @primary_key
end

#tableObject

Returns the value of attribute table.



209
210
211
# File 'lib/dbd4/dbd4_model_file.rb', line 209

def table
  @table
end

Instance Method Details

#foreign_key?Boolean

Returns:



216
217
218
# File 'lib/dbd4/dbd4_model_file.rb', line 216

def foreign_key?
  return @foreign_key != nil && @foreign_key == '1'
end

#primary_key?Boolean

Returns:



212
213
214
# File 'lib/dbd4/dbd4_model_file.rb', line 212

def primary_key?
  return @primary_key != nil && @primary_key == '1'
end

#resolve(allObjects) ⇒ Object



235
236
237
# File 'lib/dbd4/dbd4_model_file.rb', line 235

def resolve(allObjects)
  @datatype.resolve(allObjects)
end

#to_strObject



239
240
241
# File 'lib/dbd4/dbd4_model_file.rb', line 239

def to_str
  "Column(id=#{id}, name=#{name}, pkey=#{primary_key?}, fkey=#{foreign_key?}, poly=#{polymorphic}, non_standard=#{non_standard_name}, " + datatype.to_str + ")"
end

#validate(messages) ⇒ Object



231
232
233
# File 'lib/dbd4/dbd4_model_file.rb', line 231

def validate(messages)
  @datatype.validate(messages)
end