Class: Eventosaurus::TableManagerService

Inherits:
Object
  • Object
show all
Defined in:
lib/eventosaurus/services/table_manager_service.rb

Class Method Summary collapse

Class Method Details

.create_tablesObject



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/eventosaurus/services/table_manager_service.rb', line 4

def create_tables
  load_events

  existing_table_names = list_tables
  Eventosaurus.event_table_definitions.each do |definition|
    full_name = full_table_name(definition[:name])
    next if existing_table_names.include?(full_name)

    new_table = table_from_definition(definition).to_hash
    api_create_table(new_table.to_hash)
  end
end

.describe_tablesObject



26
27
28
29
30
31
32
# File 'lib/eventosaurus/services/table_manager_service.rb', line 26

def describe_tables
  load_events

  Eventosaurus.event_table_definitions.map do |definition|
    table_from_definition(definition).to_hash
  end
end

.drop_tablesObject



22
23
24
# File 'lib/eventosaurus/services/table_manager_service.rb', line 22

def drop_tables
  api_drop_tables
end

.full_table_name(table_name) ⇒ Object



34
35
36
# File 'lib/eventosaurus/services/table_manager_service.rb', line 34

def full_table_name(table_name)
  "#{Eventosaurus.configuration.environment_prefix}_#{table_name}"
end

.list_tablesObject



17
18
19
20
# File 'lib/eventosaurus/services/table_manager_service.rb', line 17

def list_tables
  prefix = Eventosaurus.configuration.environment_prefix
  api_list_tables.table_names.select { |table_name| table_name.start_with?(prefix) }
end