Class: Friendly::TableCreator
- Inherits:
-
Object
- Object
- Friendly::TableCreator
- Defined in:
- lib/friendly/table_creator.rb
Instance Attribute Summary collapse
-
#attr_klass ⇒ Object
readonly
Returns the value of attribute attr_klass.
-
#db ⇒ Object
readonly
Returns the value of attribute db.
Instance Method Summary collapse
- #create(table) ⇒ Object
-
#initialize(db = Friendly.db, attr_klass = Friendly::Attribute) ⇒ TableCreator
constructor
A new instance of TableCreator.
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_klass ⇒ Object (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 |
#db ⇒ Object (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 |