Class: WithModel::Model::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/with_model/model/dsl.rb

Instance Method Summary collapse

Constructor Details

#initialize(model) ⇒ DSL

Returns a new instance of DSL.

Parameters:



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(options = {}, &block)
  @model.table_options = options
  @model.table_block = block
end