Class: CleanSweep::TableSchema::ColumnSchema
- Inherits:
-
Object
- Object
- CleanSweep::TableSchema::ColumnSchema
- Defined in:
- lib/clean_sweep/table_schema/column_schema.rb
Instance Attribute Summary (collapse)
-
- (Object) ar_column
readonly
Returns the value of attribute ar_column.
-
- (Object) dest_name
writeonly
Sets the attribute dest_name.
-
- (Object) name
readonly
Returns the value of attribute name.
-
- (Object) select_position
Returns the value of attribute select_position.
Instance Method Summary (collapse)
- - (Object) ==(other)
-
- (ColumnSchema) initialize(name, model)
constructor
A new instance of ColumnSchema.
- - (Object) quoted_dest_name(dest_model)
- - (Object) quoted_name
- - (Object) quoted_value(row)
- - (Object) value(row)
Constructor Details
- (ColumnSchema) initialize(name, model)
Returns a new instance of ColumnSchema
7 8 9 10 11 12 |
# File 'lib/clean_sweep/table_schema/column_schema.rb', line 7 def initialize(name, model) @name = name.to_sym col_num = model.column_names.index(name.to_s) or raise "Can't find #{name} in #{model.name}" @model = model @ar_column = model.columns[col_num] end |
Instance Attribute Details
- (Object) ar_column (readonly)
Returns the value of attribute ar_column
3 4 5 |
# File 'lib/clean_sweep/table_schema/column_schema.rb', line 3 def ar_column @ar_column end |
- (Object) dest_name=(value) (writeonly)
Sets the attribute dest_name
5 6 7 |
# File 'lib/clean_sweep/table_schema/column_schema.rb', line 5 def dest_name=(value) @dest_name = value end |
- (Object) name (readonly)
Returns the value of attribute name
3 4 5 |
# File 'lib/clean_sweep/table_schema/column_schema.rb', line 3 def name @name end |
- (Object) select_position
Returns the value of attribute select_position
4 5 6 |
# File 'lib/clean_sweep/table_schema/column_schema.rb', line 4 def select_position @select_position end |
Instance Method Details
- (Object) ==(other)
30 31 32 |
# File 'lib/clean_sweep/table_schema/column_schema.rb', line 30 def == other return other && name == other.name end |
- (Object) quoted_dest_name(dest_model)
18 19 20 |
# File 'lib/clean_sweep/table_schema/column_schema.rb', line 18 def quoted_dest_name(dest_model) quote_column_name(dest_model, @dest_name || @name) end |
- (Object) quoted_name
14 15 16 |
# File 'lib/clean_sweep/table_schema/column_schema.rb', line 14 def quoted_name quote_column_name(@model, name) end |
- (Object) quoted_value(row)
26 27 28 |
# File 'lib/clean_sweep/table_schema/column_schema.rb', line 26 def quoted_value(row) @model.quote_value(value(row), @ar_column) end |
- (Object) value(row)
22 23 24 |
# File 'lib/clean_sweep/table_schema/column_schema.rb', line 22 def value(row) row[select_position] end |