From fb1f59519732c103f5e1591d9b996fd5d4423f17 Mon Sep 17 00:00:00 2001 From: Mathias Polligkeit Date: Mon, 7 Nov 2022 00:16:55 +0900 Subject: [PATCH] use Keyword.pop/3 with default value instead of Keyword.pop!/2 --- CHANGELOG.md | 8 ++++++++ README.md | 2 +- lib/let_me.ex | 6 +++--- mix.exs | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8df3ccb..2192e54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ ## Unreleased +## [1.0.1] - 2022-11-06 + +### Changed + +- Use `Keyword.pop/3` with default value instead of `Keyword.pop!/2`, so that + you can pass options to `LetMe.redact/3` without passing the `redact_value` + option. + ## [1.0.0] - 2022-11-06 ### Added diff --git a/README.md b/README.md index 22040eb..f8497ce 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Add LetMe to `mix.exs` : ```elixir def deps do [ - {:let_me, "~> 1.0.0"} + {:let_me, "~> 1.0.1"} ] end ``` diff --git a/lib/let_me.ex b/lib/let_me.ex index 7d275df..0c56f21 100644 --- a/lib/let_me.ex +++ b/lib/let_me.ex @@ -183,17 +183,17 @@ defmodule LetMe do @spec redact(struct, any, keyword) :: struct @spec redact([struct], any, keyword) :: [struct] @spec redact(nil, any, keyword) :: nil - def redact(struct, subject, opts \\ [redact_value: :redacted]) + def redact(struct, subject, opts \\ []) def redact(objects, subject, opts) when is_list(objects) do - {redact_value, opts} = Keyword.pop!(opts, :redact_value) + {redact_value, opts} = Keyword.pop(opts, :redact_value, :redacted) Enum.map(objects, &do_redact(&1, subject, redact_value, opts)) end def redact(nil, _, _), do: nil def redact(object, subject, opts) do - {redact_value, opts} = Keyword.pop!(opts, :redact_value) + {redact_value, opts} = Keyword.pop(opts, :redact_value, :redacted) do_redact(object, subject, redact_value, opts) end diff --git a/mix.exs b/mix.exs index da62d99..dac4727 100644 --- a/mix.exs +++ b/mix.exs @@ -2,7 +2,7 @@ defmodule LetMe.MixProject do use Mix.Project @source_url "https://github.com/woylie/let_me" - @version "1.0.0" + @version "1.0.1" def project do [