class WithModel::Model::DSL

Public Class Methods

new(model) click to toggle source

@param model [WithModel::Model] The Model to mutate via this DSL.

# File lib/with_model/model/dsl.rb, line 7
def initialize(model)
  @model = model
end

Public Instance Methods

model(&block) click to toggle source

Provide a class body for the ActiveRecord model.

# File lib/with_model/model/dsl.rb, line 21
def model(&block)
  @model.model_block = block
end
table(options = {}, &block) click to toggle source

Provide a schema definition for the table, passed to ActiveRecord's `create_table`. The table name will be auto-generated.

@see api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-create_table

# File lib/with_model/model/dsl.rb, line 15
def table(options = {}, &block)
  @model.table_options = options
  @model.table_block = block
end