Class: CleanSweep::TableSchema::ColumnSchema

Inherits:
Object
  • Object
show all
Defined in:
lib/clean_sweep/table_schema/column_schema.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_columnObject (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

Parameters:

  • value

    the value to set the attribute dest_name to.



5
6
7
# File 'lib/clean_sweep/table_schema/column_schema.rb', line 5

def dest_name=(value)
  @dest_name = value
end

#nameObject (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_positionObject

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_nameObject



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