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