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