Context
Inconsistent API
Main behavior is somewhat inconsistent:
@callback get(name :: atom()) :: struct() | nil
@callback set(struct :: struct()) :: {:ok, struct()}
@callback delete!(name :: atom()) :: {:ok, any()}
@callback enabled?(name :: atom()) :: boolean()
@callback enable(name :: atom()) :: {:ok, struct()}
@callback disable(name :: atom()) :: {:ok, struct()}
get should probably return {:ok, struct()} to match set return values
- It's quite ok to return just a boolean for
enabled?, but we may not need to return anything other than a plain :ok for enable and disable
delete! should probably drop its exclamation mark. I don't remember why I added it there and not on set (IIRC, I think I dropped it for set)
- Yup, looks like
delete! escaped the slashing: 19d6f6f
- Error specs should probably be added
Code quality
I think code quality could be greatly improved, eg. by:
- Using
with when relevant
- Dropping nested cases
- Separating behavior with macro definition
- Making sure errors are correctly checked (
|> Type.load() looks sus).
Context
Inconsistent API
Main behavior is somewhat inconsistent:
getshould probably return{:ok, struct()}to matchsetreturn valuesenabled?, but we may not need to return anything other than a plain:okforenableanddisabledelete!should probably drop its exclamation mark. I don't remember why I added it there and not onset(IIRC, I think I dropped it forset)delete!escaped the slashing: 19d6f6fCode quality
I think code quality could be greatly improved, eg. by:
withwhen relevant|> Type.load()looks sus).