Class: NeonPostgres::InterDatabaseCopy::MatterTemplateCopier
- Inherits:
-
Object
- Object
- NeonPostgres::InterDatabaseCopy::MatterTemplateCopier
- Defined in:
- lib/neon_postgres/inter_database_copy/matter_template_copier.rb
Class Method Summary collapse
Instance Method Summary collapse
- #copy ⇒ Object
-
#initialize(from_connection:, to_connection:) ⇒ MatterTemplateCopier
constructor
A new instance of MatterTemplateCopier.
Constructor Details
#initialize(from_connection:, to_connection:) ⇒ MatterTemplateCopier
Returns a new instance of MatterTemplateCopier.
16 17 18 19 |
# File 'lib/neon_postgres/inter_database_copy/matter_template_copier.rb', line 16 def initialize(from_connection:, to_connection:) @from_connection = from_connection @to_connection = to_connection end |
Class Method Details
.copy(from_connection: NeonPostgres::Database.from_connection, to_connection: NeonPostgres::Database.to_connection) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/neon_postgres/inter_database_copy/matter_template_copier.rb', line 6 def self.copy( from_connection: NeonPostgres::Database.from_connection, to_connection: NeonPostgres::Database.to_connection ) new( from_connection: from_connection, to_connection: to_connection ).copy end |
Instance Method Details
#copy ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/neon_postgres/inter_database_copy/matter_template_copier.rb', line 21 def copy from_dataset.each do |row| to_dataset .insert_conflict( target: :name, update: { category: Sequel[:excluded][:category], description: Sequel[:excluded][:description] } ).insert(row) end end |