class Purview::Tables::BaseSyncable
Public Instance Methods
created_timestamp_column()
click to toggle source
# File lib/purview/tables/base_syncable.rb, line 4 def created_timestamp_column column_from_opts_of_type(Purview::Columns::CreatedTimestamp) or raise %{Must specify a column of type: "#{Purview::Columns::CreatedTimestamp}"} end
created_timestamp_index()
click to toggle source
# File lib/purview/tables/base_syncable.rb, line 8 def created_timestamp_index Purview::Indices::Simple.new(created_timestamp_column) end
id_column()
click to toggle source
# File lib/purview/tables/base_syncable.rb, line 12 def id_column column_from_opts_of_type(Purview::Columns::Id) or raise %{Must specify a column of type: "#{Purview::Columns::Id}"} end
sync(connection, window)
click to toggle source
# File lib/purview/tables/base_syncable.rb, line 16 def sync(connection, window) raw_data = puller.pull(window) parser.validate(raw_data) parsed_data = parser.parse(raw_data) loader.load( connection, parsed_data, window ) end
temporary_name()
click to toggle source
# File lib/purview/tables/base_syncable.rb, line 27 def temporary_name "#{name}_#{timestamp.to_i}" end
updated_timestamp_column()
click to toggle source
# File lib/purview/tables/base_syncable.rb, line 31 def updated_timestamp_column column_from_opts_of_type(Purview::Columns::UpdatedTimestamp) or raise %{Must specify a column of type: "#{Purview::Columns::UpdatedTimestamp}"} end
updated_timestamp_index()
click to toggle source
# File lib/purview/tables/base_syncable.rb, line 35 def updated_timestamp_index Purview::Indices::Simple.new(updated_timestamp_column) end
window_size()
click to toggle source
# File lib/purview/tables/base_syncable.rb, line 39 def window_size opts[:window_size] || (60 * 60) end
Private Instance Methods
column_from_opts_of_type(type)
click to toggle source
# File lib/purview/tables/base_syncable.rb, line 45 def column_from_opts_of_type(type) columns_opt.select { |column| column.is_a?(type) }.first end
default_columns()
click to toggle source
Calls superclass method
Purview::Tables::Base#default_columns
# File lib/purview/tables/base_syncable.rb, line 49 def default_columns super + [ id_column, created_timestamp_column, updated_timestamp_column, ] end
default_indices()
click to toggle source
Calls superclass method
Purview::Tables::Base#default_indices
# File lib/purview/tables/base_syncable.rb, line 57 def default_indices super + [ created_timestamp_index, updated_timestamp_index, ] end
extract_type_opt(opts)
click to toggle source
# File lib/purview/tables/base_syncable.rb, line 64 def extract_type_opt(opts) opts[:type] end
filter_type_opt(opts)
click to toggle source
# File lib/purview/tables/base_syncable.rb, line 68 def filter_type_opt(opts) opts.select { |key| key != :type } end
loader()
click to toggle source
# File lib/purview/tables/base_syncable.rb, line 72 def loader loader_type.new(loader_opts) end
loader_opts()
click to toggle source
# File lib/purview/tables/base_syncable.rb, line 76 def loader_opts merge_table_opt(filter_type_opt(opts[:loader])) end
loader_type()
click to toggle source
# File lib/purview/tables/base_syncable.rb, line 80 def loader_type extract_type_opt(opts[:loader]) end
merge_table_opt(opts)
click to toggle source
# File lib/purview/tables/base_syncable.rb, line 84 def merge_table_opt(opts) { :table => self }.merge(opts) end
parser()
click to toggle source
# File lib/purview/tables/base_syncable.rb, line 88 def parser parser_type.new(parser_opts) end
parser_opts()
click to toggle source
# File lib/purview/tables/base_syncable.rb, line 92 def parser_opts merge_table_opt(filter_type_opt(opts[:parser])) end
parser_type()
click to toggle source
# File lib/purview/tables/base_syncable.rb, line 96 def parser_type extract_type_opt(opts[:parser]) end
puller()
click to toggle source
# File lib/purview/tables/base_syncable.rb, line 100 def puller puller_type.new(puller_opts) end
puller_opts()
click to toggle source
# File lib/purview/tables/base_syncable.rb, line 104 def puller_opts merge_table_opt(filter_type_opt(opts[:puller])) end
puller_type()
click to toggle source
# File lib/purview/tables/base_syncable.rb, line 108 def puller_type extract_type_opt(opts[:puller]) end