Class: PostgresToRedshift::Table
- Inherits:
-
Object
- Object
- PostgresToRedshift::Table
- Defined in:
- lib/postgres_to_redshift/table.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#columns ⇒ Object
Returns the value of attribute columns.
Instance Method Summary collapse
- #columns_for_copy ⇒ Object
- #columns_for_create ⇒ Object
-
#initialize(attributes:, columns: []) ⇒ Table
constructor
A new instance of Table.
- #is_view? ⇒ Boolean
- #name ⇒ Object (also: #to_s)
- #target_table_name ⇒ Object
Constructor Details
#initialize(attributes:, columns: []) ⇒ Table
Returns a new instance of Table.
18 19 20 21 |
# File 'lib/postgres_to_redshift/table.rb', line 18 def initialize(attributes: , columns: []) self.attributes = attributes self.columns = columns end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
16 17 18 |
# File 'lib/postgres_to_redshift/table.rb', line 16 def attributes @attributes end |
#columns ⇒ Object
Returns the value of attribute columns.
16 17 18 |
# File 'lib/postgres_to_redshift/table.rb', line 16 def columns @columns end |
Instance Method Details
#columns_for_copy ⇒ Object
44 45 46 47 48 |
# File 'lib/postgres_to_redshift/table.rb', line 44 def columns_for_copy columns.map do |column| column.name_for_copy end.join(", ") end |
#columns_for_create ⇒ Object
38 39 40 41 42 |
# File 'lib/postgres_to_redshift/table.rb', line 38 def columns_for_create columns.map do |column| %Q["#{column.name}" #{column.data_type_for_copy}] end.join(", ") end |
#is_view? ⇒ Boolean
50 51 52 |
# File 'lib/postgres_to_redshift/table.rb', line 50 def is_view? attributes["table_type"] == "VIEW" end |
#name ⇒ Object Also known as: to_s
23 24 25 |
# File 'lib/postgres_to_redshift/table.rb', line 23 def name attributes["table_name"] end |
#target_table_name ⇒ Object
28 29 30 |
# File 'lib/postgres_to_redshift/table.rb', line 28 def target_table_name name.gsub(/_view$/, '') end |