From 5bfc1aeb0c2ed6a2217bc83c2bfc4435b131394b Mon Sep 17 00:00:00 2001 From: Zach Daniel Date: Thu, 23 Mar 2023 22:39:56 -0400 Subject: [PATCH] =?UTF-8?q?improvement:=20improve=20compile=20times=20with?= =?UTF-8?q?=20=F0=9F=AA=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/ash/resource/dsl.ex | 8 ++++---- lib/ash/resource/schema.ex | 7 +++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/ash/resource/dsl.ex b/lib/ash/resource/dsl.ex index b6eb4f0d..327853ab 100644 --- a/lib/ash/resource/dsl.ex +++ b/lib/ash/resource/dsl.ex @@ -189,7 +189,7 @@ defmodule Ash.Resource.Dsl do end """ ], - modules: [:destination], + no_depend_modules: [:destination], target: Ash.Resource.Relationships.HasOne, schema: Ash.Resource.Relationships.HasOne.opt_schema(), args: [:name, :destination] @@ -212,7 +212,7 @@ defmodule Ash.Resource.Dsl do """ ], target: Ash.Resource.Relationships.HasMany, - modules: [:destination], + no_depend_modules: [:destination], schema: Ash.Resource.Relationships.HasMany.opt_schema(), args: [:name, :destination] } @@ -242,7 +242,7 @@ defmodule Ash.Resource.Dsl do belongs_to :word, Word, primary_key?: true, allow_nil?: false """ ], - modules: [:destination, :through], + no_depend_modules: [:destination, :through], target: Ash.Resource.Relationships.ManyToMany, schema: Ash.Resource.Relationships.ManyToMany.opt_schema(), transform: {Ash.Resource.Relationships.ManyToMany, :transform, []}, @@ -267,7 +267,7 @@ defmodule Ash.Resource.Dsl do end """ ], - modules: [:destination], + no_depend_modules: [:destination], target: Ash.Resource.Relationships.BelongsTo, schema: Ash.Resource.Relationships.BelongsTo.opt_schema(), args: [:name, :destination] diff --git a/lib/ash/resource/schema.ex b/lib/ash/resource/schema.ex index a7d331b9..bdf8df3c 100644 --- a/lib/ash/resource/schema.ex +++ b/lib/ash/resource/schema.ex @@ -108,6 +108,13 @@ defmodule Ash.Schema do alias Ash.Query.Aggregate use Ecto.Schema @primary_key false + after_compile = @after_compile -- [{__MODULE__, :__after_compile__}] + Module.delete_attribute(__MODULE__, :after_compile) + Module.register_attribute(__MODULE__, :after_compile, accumulate: true) + + for compile_hook <- after_compile do + @after_compile compile_hook + end schema Ash.DataLayer.source(__MODULE__) do for attribute <- Ash.Resource.Info.attributes(__MODULE__),