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

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

Returns 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

#attr_klassObject (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

#dbObject (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

#create(table) ⇒ Object



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