-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow use of yamerl without starting the app #60
base: master
Are you sure you want to change the base?
Conversation
Forces an application load prior to the `application:get_env/2`
Hi! Thank you for the contribution!
I see two possible approaches:
What do you think? I have a slight preference for option 1. |
since the app resource defines the default env as Otherwise, having a forced load occur in the setup would be a good middleground 👍 |
You are right this is a better idea. Would you mind modifying your pull request to use |
@dumbbell have a look and let me know what you think 👍 My go-to style is to have a config module that'd look something like this -module(yamerl_config).
-export([
get_node_mods/0,
set_node_mods/1
]).
-spec get_node_mods() -> list(module()).
get_node_mods() ->
get_value(node_mods, []).
-spec set_node_mods(list(module())) -> ok.
set_node_mods(Value) ->
set_value(node_mods, Value).
%% Internal Functions
get_value(Key) ->
application:get_env(yamerl, Key).
get_value(Key, Default) ->
case get_value(Key) of
undefined ->
Default;
{ok, Value} ->
Value
end.
set_value(Key, Value) ->
application:set_env(yamerl, Key, Value). But I've tried to fit with the existing style 😄 |
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
For very simple parameter handling like here, I usually put that in the I like your suggestion to use dedicated functions like Otherwise, please squash all commits into one. |
Forces an application load prior to the
application:get_env/2