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.
21 22 23 |
# File 'lib/with_model/model/dsl.rb', line 21 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.
15 16 17 18 |
# File 'lib/with_model/model/dsl.rb', line 15 def table( = {}, &block) @model. = @model.table_block = block end |