Class: CleanSweep::TableSchema::ColumnSchema
- Inherits:
-
Object
- Object
- CleanSweep::TableSchema::ColumnSchema
- Defined in:
- lib/clean_sweep/table_schema/column_schema.rb
Instance Attribute Summary collapse
-
#ar_column ⇒ Object
readonly
Returns the value of attribute ar_column.
-
#dest_name ⇒ Object
writeonly
Sets the attribute dest_name.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#select_position ⇒ Object
Returns the value of attribute select_position.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(name, model) ⇒ ColumnSchema
constructor
A new instance of ColumnSchema.
- #quoted_dest_name(dest_model) ⇒ Object
- #quoted_name ⇒ Object
- #quoted_value(row) ⇒ Object
- #value(row) ⇒ Object
Constructor Details
#initialize(name, model) ⇒ ColumnSchema
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
#ar_column ⇒ Object (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 |
#dest_name=(value) ⇒ Object (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 |
#name ⇒ Object (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 |
#select_position ⇒ Object
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
#==(other) ⇒ Object
30 31 32 |
# File 'lib/clean_sweep/table_schema/column_schema.rb', line 30 def == other return other && name == other.name end |
#quoted_dest_name(dest_model) ⇒ Object
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 |
#quoted_name ⇒ Object
14 15 16 |
# File 'lib/clean_sweep/table_schema/column_schema.rb', line 14 def quoted_name quote_column_name(@model, name) end |
#quoted_value(row) ⇒ Object
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 |
#value(row) ⇒ Object
22 23 24 |
# File 'lib/clean_sweep/table_schema/column_schema.rb', line 22 def value(row) row[select_position] end |