Sha256: 8bd80973816ea319965a3ee5ecf8d98207e791d383bdb90fca7554ddc2c0b4e0

Contents?: true

Size: 765 Bytes

Versions: 13

Compression:

Stored size: 765 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(&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

      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

13 entries across 13 versions & 1 rubygems

Version Path
declare_schema-0.4.2 lib/declare_schema/extensions/active_record/fields_declaration.rb
declare_schema-0.4.1 lib/declare_schema/extensions/active_record/fields_declaration.rb
declare_schema-0.4.0 lib/declare_schema/extensions/active_record/fields_declaration.rb
declare_schema-0.3.1 lib/declare_schema/extensions/active_record/fields_declaration.rb
declare_schema-0.3.0 lib/declare_schema/extensions/active_record/fields_declaration.rb
declare_schema-0.3.0.pre.2 lib/declare_schema/extensions/active_record/fields_declaration.rb
declare_schema-0.3.0.pre.1 lib/declare_schema/extensions/active_record/fields_declaration.rb
declare_schema-0.2.0 lib/declare_schema/extensions/active_record/fields_declaration.rb
declare_schema-0.2.0.pre.1 lib/declare_schema/extensions/active_record/fields_declaration.rb
declare_schema-0.1.3 lib/declare_schema/extensions/active_record/fields_declaration.rb
declare_schema-0.1.2 lib/declare_schema/extensions/active_record/fields_declaration.rb
declare_schema-0.1.1 lib/declare_schema/extensions/active_record/fields_declaration.rb
declare_schema-0.1.0 lib/declare_schema/extensions/active_record/fields_declaration.rb