Skip to content
Open
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 CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Make sure to follow the following guidelines when doing so.
* Write [good commit messages](https://chris.beams.io/posts/git-commit/).
* Use the same coding conventions as the rest of the project.
* Commit and push until you are happy with your contribution.
* Make sure to add tests for it. So we can avoid that it breaks accidentially in the future.
* Make sure to add tests for it. So we can avoid that it breaks accidentally in the future.
* Add an entry to the [Changelog](./CHANGELOG.md) accordingly. See [changelog entry format](#changelog-entry-format).
* Open a [pull request](https://help.github.com/articles/about-pull-requests) that relates to *only* one subject with a clear title
and description in grammatically correct, complete sentences.
Expand Down
18 changes: 4 additions & 14 deletions lib/knigge/options.ex
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,15 @@ defmodule Knigge.Options do
__Default__: `nil`; `Knigge` will raise an error when no implementation is configured.

### `delegate_at_runtime?`
A switch to move delegation to runtime, by defauly `Knigge` does as much work as possible at compile time.
A switch to move delegation to runtime, by default `Knigge` does as much work as possible at compile time.
Accepts:

- a boolean (`true` always delegate at runtime | `false` always at compile time)
- one or many environment names (atom or list of atoms) - only delegate at runtime in the given environments
- `[only: <envs>]` - equivalent to the option above
- `[except: <envs>]` - only delegates at runtime if the current environment is __not__ contained in the list

__Default__: `Application.get_env(:knigge, :delegate_at_runtime?, #{
inspect(@defaults[:delegate_at_runtime?])
})`
__Default__: `Application.get_env(:knigge, :delegate_at_runtime?, #{inspect(@defaults[:delegate_at_runtime?])})`

### `do_not_delegate`
A keyword list defining callbacks for which no delegation should happen.
Expand Down Expand Up @@ -156,9 +154,7 @@ defmodule Knigge.Options do

message when is_binary(message) ->
IO.warn(
"Knigge encountered the deprecated option `#{key}`, this option is no longer supported; #{
message
}."
"Knigge encountered the deprecated option `#{key}`, this option is no longer supported; #{message}."
)

nil
Expand All @@ -178,13 +174,7 @@ defmodule Knigge.Options do

@doc """
Applies the defaults to the given options:
#{
@defaults
|> Enum.map(fn {key, value} ->
" - #{key} = #{inspect(value)}"
end)
|> Enum.join("\n")
}
#{@defaults |> Enum.map(fn {key, value} -> " - #{key} = #{inspect(value)}" end) |> Enum.join("\n")}
"""
@spec with_defaults(raw()) :: raw()
def with_defaults(opts) do
Expand Down
4 changes: 1 addition & 3 deletions lib/knigge/warnings.ex
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ defmodule Knigge.Warnings do

There are two ways to resolve this warning:
1. move the behaviour into a separate module and `use Knigge, behaviour: MyBehaviour`;
this enables to compiler to finish compilation of `#{inspect(implementation)}` before compiling `#{
inspect(module)
}`
this enables to compiler to finish compilation of `#{inspect(implementation)}` before compiling `#{inspect(module)}`
2. pass `delegate_at_runtime?: true` as option, this will move **all** delegation to runtime
""")
end
Expand Down
4 changes: 1 addition & 3 deletions test/behaviour/with_defdefault_for_open_module_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ defmodule Behaviour.WithDefdefaultForOpenModuleTest do

There are two ways to resolve this warning:
1. move the behaviour into a separate module and `use Knigge, behaviour: MyBehaviour`;
this enables to compiler to finish compilation of `#{inspect(implementation)}` before compiling `#{
inspect(facade)
}`
this enables to compiler to finish compilation of `#{inspect(implementation)}` before compiling `#{inspect(facade)}`
2. pass `delegate_at_runtime?: true` as option, this will move **all** delegation to runtime
"""
)
Expand Down
2 changes: 1 addition & 1 deletion test/knigge/options_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ defmodule Knigge.OptionsTest do
"Knigge encountered the deprecated option `delegate_at`, please use `delegate_at_runtime?`."
end

test "rasies an exception for an invalid `default` value" do
test "raises an exception for an invalid `default` value" do
message =
"Knigge received invalid value for `default`. Expected module but received: \"invalid\""

Expand Down
2 changes: 1 addition & 1 deletion test/knigge/verification_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ defmodule Knigge.VerificationTest do
defmodule FacadeWithoutImpl do
use Knigge,
implementation: Does.Not.Exist,
# Surpresses some warnings
# Suppresses some warnings
delegate_at_runtime?: true

@callback some_function() :: :ok
Expand Down