Sha256: f2e3a99537bfce682609c3136e0395b18f905430e06b5059011e9083a2fc4ac6

Contents?: true

Size: 679 Bytes

Versions: 1

Compression:

Stored size: 679 Bytes

Contents

# frozen_string_literal: true

module WithModel
  class Model
    class 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

1 entries across 1 versions & 1 rubygems

Version Path
with_model-2.1.0 lib/with_model/model/dsl.rb