riverrun / openmaize

No longer maintained - was an Authentication library for Plug-based applications in Elixir
Other
206 stars 30 forks source link

Add db_module to Openmaize.Config #56

Closed zimt28 closed 8 years ago

zimt28 commented 8 years ago

It would be nice if we could add the db_module to the config once, instead of adding it to every plug etc.

config :openmaize,
  db_module: Welcome.OpenmaizeEcto

Is there any reason against it?

Edit: Same for unique_id

riverrun commented 8 years ago

The main reason for using keyword arguments, instead of the config, is that it allows the developer the freedom to use different values in different parts of the app. As it is now, if the developer can use a different db_module, or unique_id, in a part of the app.

zimt28 commented 8 years ago

I see, but often times this won't change. It would be great to allow a custom default value, which can be overwritten using the current syntax.

This way people who have one db_module and unique_id could get cleaner code, those who have more could still choose every time they use Openmaize's plugs.

riverrun commented 8 years ago

In the latest version - updated earlier today - db_module defaults to the name generated by openmaize.gen.ectodb, that is, MyApp.OpenmaizeEcto, so for most people there should be no need to set it directly. unique_id defaults to username. You can see how the changes are used in the example app.