constants - ?define macro or .hrl file alternate in Elixir for configuration purpose -


in erlang can use define macro or .hrl file keep configuration @ 1 place. whats best place in elixir.

i couldn't find elegant way of doing it. right doing like:-

def get_server_name     "test" end 

am missing something?

whether use functions or macros should matter in end, if you're looking "keeping in 1 place" part, i'd suggest putting in own namespace/module

defmodule myapp.configuration   def server_name     "foo"   end    # or if prefer having on 1 line   def host_name, do: "example.com"    # complete equivalency, can use macro   defmacro other_config     "some value"   end end 

and in app, instead of including file, can alias module have short prefix indicate it's configuration, , indicate come elsewhere

defmodule myapp.server   alias myapp.configuration, as: c end 

or if want use names directly

defmodule myapp.server   import myapp.configuration end 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -