Class: Chicago::Database::SchemaGenerator Private

Inherits:
Object
  • Object
show all
Defined in:
lib/chicago/database/schema_generator.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A StarSchema Visitor which produces a hash similar to the hash produced by Sequel.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(database_strategy, generate_key_tables = true) ⇒ SchemaGenerator

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of SchemaGenerator.



8
9
10
11
# File 'lib/chicago/database/schema_generator.rb', line 8

def initialize(database_strategy, generate_key_tables=true)
  @database_strategy = database_strategy
  @generate_key_tables = generate_key_tables
end

Instance Attribute Details

#database_strategy=(value) ⇒ Object (writeonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



6
7
8
# File 'lib/chicago/database/schema_generator.rb', line 6

def database_strategy=(value)
  @database_strategy = value
end

Instance Method Details

#generate_key_tables?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


13
14
15
# File 'lib/chicago/database/schema_generator.rb', line 13

def generate_key_tables?
  @generate_key_tables
end

#traverse(schema) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



17
18
19
# File 'lib/chicago/database/schema_generator.rb', line 17

def traverse(schema)
  schema.tables.inject({}) {|hsh,t| hsh.merge(t.visit(self)) }
end

#visit_column(column) ⇒ Object Also known as: visit_measure, visit_dimension_reference

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



31
32
33
# File 'lib/chicago/database/schema_generator.rb', line 31

def visit_column(column)
  @database_strategy.column_hash(column)
end

#visit_dimension(dimension) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



25
26
27
28
29
# File 'lib/chicago/database/schema_generator.rb', line 25

def visit_dimension(dimension)
  hash = {dimension.table_name => basic_table(dimension)}
  hash.merge!(key_table(dimension)) if generate_key_tables?
  hash
end

#visit_fact(fact) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



21
22
23
# File 'lib/chicago/database/schema_generator.rb', line 21

def visit_fact(fact)
  {fact.table_name => basic_table(fact)}
end