class Cranium::ImportStrategy::Base
Attributes
import_definition[R]
Public Class Methods
new(import_definition)
click to toggle source
# File lib/cranium/import_strategy/base.rb, line 7 def initialize(import_definition) @import_definition = import_definition end
Public Instance Methods
import()
click to toggle source
# File lib/cranium/import_strategy/base.rb, line 13 def import external_table = Cranium::ExternalTable.new Cranium.application.sources[import_definition.name], Cranium::Database.connection, error_threshold: @import_definition.error_threshold external_table.create number_of_items_imported = import_from external_table.name external_table.destroy number_of_items_imported end
Protected Instance Methods
database()
click to toggle source
# File lib/cranium/import_strategy/base.rb, line 33 def database Cranium::Database.connection end
import_from(external_table)
click to toggle source
# File lib/cranium/import_strategy/base.rb, line 27 def import_from(external_table) raise StandardError "Not implemented" end
source_fields()
click to toggle source
# File lib/cranium/import_strategy/base.rb, line 45 def source_fields import_definition.field_associations.keys.map &:to_sym end
target_fields()
click to toggle source
# File lib/cranium/import_strategy/base.rb, line 51 def target_fields import_definition.field_associations.values.map &:to_sym end
target_table()
click to toggle source
# File lib/cranium/import_strategy/base.rb, line 39 def target_table import_definition.into end