Class: Friendly::TableCreator

Inherits:
Object
  • Object
show all
Defined in:
lib/friendly/table_creator.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (TableCreator) initialize(db = Friendly.db, attr_klass = Friendly::Attribute)

A new instance of TableCreator



5
6
7
8
# File 'lib/friendly/table_creator.rb', line 5

def initialize(db = Friendly.db, attr_klass = Friendly::Attribute)
  @db         = db
  @attr_klass = attr_klass
end

Instance Attribute Details

- (Object) attr_klass (readonly)

Returns the value of attribute attr_klass



3
4
5
# File 'lib/friendly/table_creator.rb', line 3

def attr_klass
  @attr_klass
end

- (Object) db (readonly)

Returns the value of attribute db



3
4
5
# File 'lib/friendly/table_creator.rb', line 3

def db
  @db
end

Instance Method Details

- (Object) create(table)



10
11
12
13
14
15
16
17
18
19
# File 'lib/friendly/table_creator.rb', line 10

def create(table)
  unless db.table_exists?(table.table_name)
    case table
    when DocumentTable
      create_document_table(table) 
    when Index
      create_index_table(table)
    end
  end
end