Sha256: 7a5a76e66ec37ceea69e548cbc4f01b476622d54caf61499e5bad96ab83f3147

Contents?: true

Size: 753 Bytes

Versions: 4

Compression:

Stored size: 753 Bytes

Contents

# frozen_string_literal: true

module WithModel
  class Model
    class DSL
      # @param model [WithModel::Model] The Model to mutate via this DSL.
      def initialize(model)
        @model = model
      end

      # Provide a schema definition for the table, passed to ActiveRecord’s `create_table`.
      # The table name will be auto-generated.
      #
      # @see https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-create_table
      def table(options = {}, &block)
        @model.table_options = options
        @model.table_block = block
      end

      # Provide a class body for the ActiveRecord model.
      def model(&block)
        @model.model_block = block
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
with_model-2.1.4 lib/with_model/model/dsl.rb
with_model-2.1.3 lib/with_model/model/dsl.rb
with_model-2.1.2 lib/with_model/model/dsl.rb
with_model-2.1.1 lib/with_model/model/dsl.rb