Class: WithModel::Model::DSL
- Inherits:
-
Object
- Object
- WithModel::Model::DSL
- Defined in:
- lib/with_model/model/dsl.rb
Instance Method Summary collapse
-
#initialize(model) ⇒ DSL
constructor
A new instance of DSL.
-
#model(&block) ⇒ Object
Provide a class body for the ActiveRecord model.
-
#table(options = {}, &block) ⇒ Object
Provide a schema definition for the table, passed to ActiveRecord's
create_table.
Constructor Details
#initialize(model) ⇒ DSL
Returns a new instance of DSL.
7 8 9 |
# File 'lib/with_model/model/dsl.rb', line 7 def initialize(model) @model = model end |
Instance Method Details
#model(&block) ⇒ Object
Provide a class body for the ActiveRecord model.
24 25 26 |
# File 'lib/with_model/model/dsl.rb', line 24 def model(&block) @model.model_block = block end |
#table(options = {}, &block) ⇒ Object
Provide a schema definition for the table, passed to ActiveRecord's create_table.
The table name will be auto-generated.
Pass false instead of options to create no table at all, so that the
model inherits its superclass's table as Rails Single Table Inheritance
requires. table(false) takes no block.
19 20 21 |
# File 'lib/with_model/model/dsl.rb', line 19 def table( = {}, &block) @model.specify_table(, block) end |