diff --git a/README.md b/README.md index 7b5b11d..292c007 100644 --- a/README.md +++ b/README.md @@ -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? diff --git a/mix.exs b/mix.exs index cc69efd..03532a1 100644 --- a/mix.exs +++ b/mix.exs @@ -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" diff --git a/outstanding.livemd b/outstanding.livemd index 9a8e459..111c9e1 100644 --- a/outstanding.livemd +++ b/outstanding.livemd @@ -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 @@ -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 @@ -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.