class Cranium::ImportStrategy::Delete
Public Instance Methods
import_from(source_table)
click to toggle source
# File lib/cranium/import_strategy/delete.rb, line 3 def import_from(source_table) @source_table = source_table delete_existing_records puts @source_table database[@source_table].count end
Private Instance Methods
delete_by_fields()
click to toggle source
# File lib/cranium/import_strategy/delete.rb, line 24 def delete_by_fields Cranium::Sequel::Hash[delete_field_mapping] end
delete_existing_records()
click to toggle source
# File lib/cranium/import_strategy/delete.rb, line 15 def delete_existing_records database. from(Sequel.as(target_table, "target"), Sequel.as(@source_table, "source")). where(delete_by_fields.qualify keys_with: :source, values_with: :target). delete end
delete_field_mapping()
click to toggle source
# File lib/cranium/import_strategy/delete.rb, line 30 def delete_field_mapping import_definition.field_associations.select { |_, target_field| import_definition.delete_on.include? target_field } end