class Janko::Import
Public Instance Methods
columns(*columns)
click to toggle source
# File lib/janko/import.rb, line 38 def columns(*columns) @state[:columns] = columns.flatten self end
connect(connection)
click to toggle source
# File lib/janko/import.rb, line 28 def connect(connection) @state[:connection] = Connection.build(connection) self end
default_state()
click to toggle source
# File lib/janko/import.rb, line 24 def default_state { columns: Janko::ALL, importer: Janko::CopyImporter } end
push(values)
click to toggle source
# File lib/janko/import.rb, line 49 def push(values) raise("Call #start before #push") unless @state[:started] delegate.push(values) self end
start()
click to toggle source
# File lib/janko/import.rb, line 43 def start @state[:started] = true delegate.start self end
stop()
click to toggle source
# File lib/janko/import.rb, line 55 def stop raise("Call #start before #stop") unless @state[:started] delegate.stop @state[:started] = false self end
use(importer)
click to toggle source
# File lib/janko/import.rb, line 33 def use(importer) @state[:importer] = importer self end
Private Instance Methods
delegate()
click to toggle source
# File lib/janko/import.rb, line 69 def delegate @delegate ||= @state[:importer].new(delegate_options) end
delegate_options()
click to toggle source
# File lib/janko/import.rb, line 73 def delegate_options raise("No table specified.") unless @state[:table] column_list = ColumnList.build(@state[:columns]) raise("No columns specified.") if column_list.empty? @state.merge(columns: column_list) end
preserve_state_if_started()
click to toggle source
# File lib/janko/import.rb, line 64 def preserve_state_if_started return(self) unless @state[:started] raise("Call #stop before changing import options.") end