Module: Mongify::Translation::Process

Included in:
Mongify::Translation
Defined in:
lib/mongify/translation/process.rb

Overview

This module does the processing on the translation object

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#no_sql_connectionObject

Returns the value of attribute no_sql_connection.



7
8
9
# File 'lib/mongify/translation/process.rb', line 7

def no_sql_connection
  @no_sql_connection
end

#sql_connectionObject

Returns the value of attribute sql_connection.



7
8
9
# File 'lib/mongify/translation/process.rb', line 7

def sql_connection
  @sql_connection
end

Instance Method Details

#process(sql_connection, no_sql_connection) ⇒ Object

Does the actual act of processing the translation. Takes in boht a sql connection and a no sql connection



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/mongify/translation/process.rb', line 10

def process(sql_connection, no_sql_connection)
  raise Mongify::SqlConnectionRequired, "Can only read from Mongify::Database::SqlConnection" unless sql_connection.is_a?(Mongify::Database::SqlConnection)
  raise Mongify::NoSqlConnectionRequired, "Can only write to Mongify::Database::NoSqlConnection" unless no_sql_connection.is_a?(Mongify::Database::NoSqlConnection)
  
  self.sql_connection = sql_connection
  raise SqlConnectionInvalid, "SQL Connection is not valid" unless self.sql_connection.valid?
  self.no_sql_connection = no_sql_connection
  raise NoSqlConnectionInvalid, "noSql Connection is not valid" unless self.no_sql_connection.valid?
  
  no_sql_connection.ask_to_drop_database if no_sql_connection.forced?
  
  setup_db_index
  copy_data
  copy_embedded_tables
  update_reference_ids
  copy_polymorphic_tables
  remove_pre_mongified_ids
  nil
end