Skip to content

Commit

Permalink
fix: Allow MFA tuple to be given sanitizer config
Browse files Browse the repository at this point in the history
  • Loading branch information
rai200890 committed Jan 23, 2020
1 parent 62845ac commit eaebb19
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.7.0
0.7.1
11 changes: 9 additions & 2 deletions lib/job.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit eaebb19

Please sign in to comment.