Skip to content

Commit

Permalink
fix entity and event (#56)
Browse files Browse the repository at this point in the history
* fix: async tests

* fix: event and entity
  • Loading branch information
yordis committed Dec 24, 2022
1 parent aafefdc commit 5be413c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 20 deletions.
4 changes: 4 additions & 0 deletions apps/one_piece_commanded/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## v0.15.1 - 2022-12-24

- Fix `OnePiece.Commanded.Event` and ``OnePiece.Commanded.Entity` to extend from `OnePiece.Commanded.ValueObject`.

## v0.15.0 - 2022-12-23

- Added overridable to `OnePiece.Commanded.ValueObject.new/1`
Expand Down
7 changes: 3 additions & 4 deletions apps/one_piece_commanded/lib/one_piece/commanded/entity.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,19 @@ defmodule OnePiece.Commanded.Entity do
quote do
use OnePiece.Commanded.ValueObject

@identifier_key unquote(identifier)
@primary_key {@identifier_key, :string, autogenerate: false}

@typedoc """
The key used to identify the entity.
"""
@type identifier_key :: unquote(identifier)

@primary_key {unquote(identifier), :string, autogenerate: false}

@doc """
Returns the identity field of the entity.
"""
@spec identifier :: identifier_key()
def identifier do
@identifier_key
unquote(identifier)
end
end
end
Expand Down
18 changes: 3 additions & 15 deletions apps/one_piece_commanded/lib/one_piece/commanded/event.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ defmodule OnePiece.Commanded.Event do
Defines "Event" modules.
"""

alias OnePiece.Commanded.Helpers

@type t :: struct()

@doc """
Expand All @@ -31,31 +29,21 @@ defmodule OnePiece.Commanded.Event do
aggregate_identifier = Keyword.fetch!(opts, :aggregate_identifier)

quote do
use Ecto.Schema
use OnePiece.Commanded.ValueObject

@typedoc """
The key used to identify the aggregate.
"""
@type aggregate_identifier_key :: unquote(aggregate_identifier)

@aggregate_identifier_key unquote(aggregate_identifier)
@primary_key {@aggregate_identifier_key, :string, autogenerate: false}
@derive Jason.Encoder

@doc """
Creates a new `t:t/0` command.
"""
@spec new(attrs :: map()) :: struct()
def new(attrs) do
Helpers.struct_from(attrs, __MODULE__)
end
@primary_key {unquote(aggregate_identifier), :string, autogenerate: false}

@doc """
Returns the aggregate identifier key.
"""
@spec aggregate_identifier :: aggregate_identifier_key()
def aggregate_identifier do
@aggregate_identifier_key
unquote(aggregate_identifier)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion apps/one_piece_commanded/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ defmodule OnePiece.Commanded.MixProject do
use Mix.Project

@app :one_piece_commanded
@version "0.15.0"
@version "0.15.1"
@elixir_version "~> 1.13"
@source_url "https://github.com/straw-hat-team/beam-monorepo"

Expand Down

0 comments on commit 5be413c

Please sign in to comment.