Module: ORMakers::Model
- Defined in:
- lib/ormakers/model.rb
Overview
Database model module
Defined Under Namespace
Modules: ClassMethods, InstanceMethods
Class Method Summary collapse
Class Method Details
.create_table_for_model(model) ⇒ Object
4 5 6 7 8 |
# File 'lib/ormakers/model.rb', line 4 def self.create_table_for_model(model) Database.query("CREATE TABLE #{model.name.snake_case}s (id serial);") rescue PG::DuplicateTable 'Model table already exists' end |
.included(model_class) ⇒ Object
10 11 12 13 14 |
# File 'lib/ormakers/model.rb', line 10 def self.included(model_class) create_table_for_model(model_class) model_class.send(:include, InstanceMethods) model_class.extend(ClassMethods) end |