mirror of
https://github.com/ash-project/ash.git
synced 2024-09-20 05:23:03 +12:00
fix: don't fail to build Phoenix.Socket.Broadcast
This commit is contained in:
parent
d0c28ec215
commit
7930e3efa1
4 changed files with 20 additions and 40 deletions
|
@ -21,7 +21,7 @@ The available aggregate types are:
|
|||
- `sum` - sums the related items meeting the criteria. Must specify the `field` to sum.
|
||||
- `list` - lists the related values. Must specify the `field` to list.
|
||||
|
||||
See the docs on {{link:ash:dsl:aggregates/aggregate}} for more information.
|
||||
See the docs on {{link:ash:dsl:resource/aggregates}} for more information.
|
||||
|
||||
The aggregates declared on a resource allow for declaring a set of named aggregates that can be used by extensions.
|
||||
|
||||
|
|
|
@ -202,46 +202,26 @@ defmodule Ash.Notifier.PubSub do
|
|||
end)
|
||||
end
|
||||
|
||||
case Code.ensure_compiled(Phoenix.Socket.Broadcast) do
|
||||
{:module, _} ->
|
||||
def to_payload(topic, event, notification) do
|
||||
case Ash.Notifier.PubSub.Info.broadcast_type(notification.resource) do
|
||||
:phoenix_broadcast ->
|
||||
%Phoenix.Socket.Broadcast{
|
||||
topic: topic,
|
||||
event: event,
|
||||
payload: notification
|
||||
}
|
||||
def to_payload(topic, event, notification) do
|
||||
case Ash.Notifier.PubSub.Info.broadcast_type(notification.resource) do
|
||||
:phoenix_broadcast ->
|
||||
%{
|
||||
__struct__: Phoenix.Socket.Broadcast,
|
||||
topic: topic,
|
||||
event: event,
|
||||
payload: notification
|
||||
}
|
||||
|
||||
:broadcast ->
|
||||
%{
|
||||
topic: topic,
|
||||
event: event,
|
||||
payload: notification
|
||||
}
|
||||
:broadcast ->
|
||||
%{
|
||||
topic: topic,
|
||||
event: event,
|
||||
payload: notification
|
||||
}
|
||||
|
||||
:notification ->
|
||||
notification
|
||||
end
|
||||
end
|
||||
|
||||
_ ->
|
||||
def to_payload(topic, event, notification) do
|
||||
case Ash.Notifier.PubSub.Info.broadcast_type(notification.resource) do
|
||||
:phoenix_broadcast ->
|
||||
raise "A resource was configured with `broadcast_type :phoenix_broadcast` but `Phoenix.Socket.Broadcast` was not compiled."
|
||||
|
||||
:broadcast ->
|
||||
%{
|
||||
topic: topic,
|
||||
event: event,
|
||||
payload: notification
|
||||
}
|
||||
|
||||
:notification ->
|
||||
notification
|
||||
end
|
||||
end
|
||||
:notification ->
|
||||
notification
|
||||
end
|
||||
end
|
||||
|
||||
defp fill_template(topic, _) when is_binary(topic), do: [topic]
|
||||
|
|
|
@ -51,7 +51,7 @@ defmodule Ash.Registry.Dsl do
|
|||
@moduledoc """
|
||||
A small DSL for declaring an `Ash.Registry`.
|
||||
|
||||
`Ash.Registry` can be used generically, but the main way it is used in Ash is to provide a compile-time registry for {{link:ash:guide:Apis}}.
|
||||
`Ash.Registry` can be used generically, but the main way it is used in Ash is to provide a compile-time registry for an Ash Api.
|
||||
|
||||
<!--- ash-hq-hide-start--> <!--- -->
|
||||
|
||||
|
|
Loading…
Reference in a new issue