Sha256: 0c7ea964c9fd72f499a775a9d58c7d55b91769883da4c86eff6147badde554f5

Contents?: true

Size: 829 Bytes

Versions: 18

Compression:

Stored size: 829 Bytes

Contents

# frozen_string_literal: true

require 'active_record'
require 'declare_schema/model'
require 'declare_schema/field_declaration_dsl'

module DeclareSchema
  module FieldsDsl
    def fields(table_options = {}, &block)
      # Any model that calls 'fields' gets DeclareSchema::Model behavior
      DeclareSchema::Model.mix_in(self)

      # @include_in_migration = false #||= options.fetch(:include_in_migration, true); options.delete(:include_in_migration)
      @include_in_migration = true
      @table_options        = table_options

      if block
        dsl = DeclareSchema::FieldDeclarationDsl.new(self, null: false)
        if block.arity == 1
          yield dsl
        else
          dsl.instance_eval(&block)
        end
      end
    end
  end
end

ActiveRecord::Base.singleton_class.prepend DeclareSchema::FieldsDsl

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
declare_schema-0.8.0 lib/declare_schema/extensions/active_record/fields_declaration.rb
declare_schema-0.8.0.pre.6 lib/declare_schema/extensions/active_record/fields_declaration.rb
declare_schema-0.8.0.pre.5 lib/declare_schema/extensions/active_record/fields_declaration.rb
declare_schema-0.8.0.pre.4 lib/declare_schema/extensions/active_record/fields_declaration.rb
declare_schema-0.8.0.pre.3 lib/declare_schema/extensions/active_record/fields_declaration.rb
declare_schema-0.8.0.pre.2 lib/declare_schema/extensions/active_record/fields_declaration.rb
declare_schema-0.8.0.pre.1 lib/declare_schema/extensions/active_record/fields_declaration.rb
declare_schema-0.7.1 lib/declare_schema/extensions/active_record/fields_declaration.rb
declare_schema-0.7.0 lib/declare_schema/extensions/active_record/fields_declaration.rb
declare_schema-0.6.4 lib/declare_schema/extensions/active_record/fields_declaration.rb
declare_schema-0.6.3 lib/declare_schema/extensions/active_record/fields_declaration.rb
declare_schema-0.6.2 lib/declare_schema/extensions/active_record/fields_declaration.rb
declare_schema-0.6.1 lib/declare_schema/extensions/active_record/fields_declaration.rb
declare_schema-0.6.0 lib/declare_schema/extensions/active_record/fields_declaration.rb
declare_schema-0.5.0 lib/declare_schema/extensions/active_record/fields_declaration.rb
declare_schema-0.5.0.pre.3 lib/declare_schema/extensions/active_record/fields_declaration.rb
declare_schema-0.5.0.pre.2 lib/declare_schema/extensions/active_record/fields_declaration.rb
declare_schema-0.5.0.pre.1 lib/declare_schema/extensions/active_record/fields_declaration.rb