I’m loading application-wide variables from a yaml file, and one of
them is a symbol
development:
LDAP_HOST: ‘ldap.x.edu.au’
LDAP_PORT: ‘636’
LDAP_ENC: ‘:simple_tls’
…
That works fine, and I use the vars like this:
ldap_con = Net::LDAP.new(
:host => APP_CONFIG['LDAP_HOST'],
:port => APP_CONFIG['LDAP_PORT'],
:encryption => {:method => eval(APP_CONFIG['LDAP_ENC'].to_s)}
)
Converting the third variable LDAP_ENC to a string, then evaluating it
looks ugly. Is there a better way to draw on symbols from a yaml
file?
Or how about a syntax to dynamically specify the name of the symbol if
what’s stored in the yaml file is just
LDAP_ENC: ‘simple_tls’
thanks!
George Bray, The Australian National University, Canberra, Australia.