diff --git a/CHANGELOG.md b/CHANGELOG.md index e8dc2d4..7492fd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.7.1] - 2020-01-23 + +### Fixes + +- Allow MFA tuple to be given to sanitizer config + ## [0.7.0] - 2020-01-22 ### Added diff --git a/VERSION b/VERSION index bcaffe1..7deb86f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.7.0 \ No newline at end of file +0.7.1 \ No newline at end of file diff --git a/lib/job.ex b/lib/job.ex index 900def3..6d79cb5 100644 --- a/lib/job.ex +++ b/lib/job.ex @@ -25,7 +25,7 @@ defmodule EctoJobScheduler.Job do {context, params} = Map.pop(params, "context", %{}) job_context = %{ - "params" => params |> sanitizer().(), + "params" => sanitize(params), "attempt" => attempt, "max_attempts" => max_attempts } @@ -88,10 +88,17 @@ defmodule EctoJobScheduler.Job do end end - def sanitizer do + defp sanitizer do Application.get_env(:ecto_job_scheduler, :sanitizer, fn param -> param end) end + defp sanitize(params) do + case sanitizer() do + fun when is_function(fun) -> fun.(params) + {mod, fun_name} -> apply(mod, fun_name, [params]) + end + end + def config do merged_options = @default_options