Class: Eg::ColumnIndex::Column

Inherits:
Object
  • Object
show all
Defined in:
lib/eg/column_index.rb

Overview

Helper class

Constant Summary collapse

@@metadata =
{ 'column_name' => String, 'column_type' => Class, 'column' => Object, 'class_name' => Class }

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#class_nameObject

Returns the value of attribute class_name.



68
69
70
# File 'lib/eg/column_index.rb', line 68

def class_name
  @class_name
end

#columnObject

Returns the value of attribute column.



68
69
70
# File 'lib/eg/column_index.rb', line 68

def column
  @column
end

#column_nameObject

Returns the value of attribute column_name.



68
69
70
# File 'lib/eg/column_index.rb', line 68

def column_name
  @column_name
end

#column_typeObject

Returns the value of attribute column_type.



68
69
70
# File 'lib/eg/column_index.rb', line 68

def column_type
  @column_type
end

Class Method Details

.create(obj, attribute) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
# File 'lib/eg/column_index.rb', line 71

def Column.create obj, attribute
  c = new
  c.column = attribute
  c.class_name = obj.class
  column_name = attribute.to_s
  column_name_parts = column_name.split(/_/)
  c.column_name = column_name_parts.shift
  column_name_parts.each {|name| c.column_name += name.capitalize}
  c.column_type = obj.class.[column_name]
  c
end

.metadataObject



70
# File 'lib/eg/column_index.rb', line 70

def Column.; @@metadata; end