Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ end

To get started you need a running instance of [Livebook](https://livebook.dev/)

[![Run in Livebook](https://livebook.dev/badge/v1/blue.svg)](https://livebook.dev/run?url=https%3A%2F%2Fgithub.com%2Fdiffo%2Ddev%2Foutstanding%2Fblob%2Fdev%2Foutstanding.livemd)
[![Run in Livebook](https://livebook.dev/badge/v1/blue.svg)](https://github.com/diffo-dev/outstanding/blob/dev/outstanding.livemd)

## Outstanding?

Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ defmodule Outstanding.MixProject do
name: @name,
licenses: ["MIT"],
files: ~w(lib .formatter.exs mix.exs README* LICENSE*
CHANGELOG* documentation),
CHANGELOG*),
links: %{
"GitHub" => @github_url,
"Author's home page" => "https://www.diffo.dev"
Expand Down
23 changes: 20 additions & 3 deletions outstanding.livemd
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ Now resolve the second child by setting its actual ```state: :active``` and ```s

## How to implement Outstanding for your Types And Structs

You can easily implement Outstandign on Structs and other Types
You can easily implement Outstanding on Structs and other Types

### Derive Outstanding on your Structs

Expand All @@ -206,8 +206,25 @@ When you define your struct you can simply @derive the Outstanding protocol. By
@derive Outstanding
defstruct [:a, :b, :c]
end
```

Then we can evaluate outstanding on our new struct:

```elixir
Outstanding.outstanding(%ABC{a: "apple", b: "banana", c: "carrot"}, %ABC{a: "apple", b: "bagel", c: "cake"})
```

We can also use the ```except``` option to exclude fields:

outstanding(%ABC{a: "apple", b: "banana", c: "carrot"}, %ABC{a: "apple", b: "bagel", c: "cake"})
```elixir
defmodule AB do
@derive {Outstanding, except: [:c]}
defstruct [:a, :b, :c]
end
```

```elixir
Outstanding.outstanding(%AB{a: "apple", b: "banana", c: "carrot"}, %AB{a: "apple", b: "bagel", c: "cake"})
```

### Outstanding on any Type
Expand Down Expand Up @@ -253,7 +270,7 @@ These tests can be executed
ExUnit.run()
```

### Outstanding on Structs
### Outstanding on your Struct using defoutstanding

When implementing Outstanding for a struct, you need to think about what fields you wish to run outstanding on,
what your expectation is for each field, and whether you require actual to have the same struct name, or even be a struct at all.
Expand Down