Module: Legion::Extensions::Helpers::Core

Includes:
Base, Settings::Helper
Included in:
Lex
Defined in:
lib/legion/extensions/helpers/core.rb

Constant Summary

Constants included from Base

Base::NAMESPACE_BOUNDARIES

Instance Method Summary collapse

Methods included from Base

#actor_class, #actor_const, #actor_name, #amqp_prefix, #calling_class, #calling_class_array, #from_json, #full_path, #lex_class, #lex_const, #lex_name, #lex_slug, #log_tag, #normalize, #runner_class, #runner_const, #runner_name, #segments, #settings_path, #table_prefix, #to_dotted_hash

Instance Method Details

#find_setting(name, **opts) ⇒ Object

looks local, then in crypt, then settings, then cache, then env



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/legion/extensions/helpers/core.rb', line 14

def find_setting(name, **opts)
  log.debug ".find_setting(#{name}) called"
  return opts[name.to_sym] if opts.key? name.to_sym

  string_name = "#{lex_name}_#{name.to_s.downcase}"
  if Legion::Settings[:crypt][:vault][:connected] && Legion::Crypt.exist?(lex_name)
    log.debug "looking for #{string_name} in Legion::Crypt"
    crypt_result = Legion::Crypt.get(lex_name)
    return crypt_result[name.to_sym] if crypt_result.is_a?(Hash) && crypt_result.key?(name.to_sym)
  end
  return settings[name.to_sym] if settings.key? name.to_sym

  if Legion::Settings[:cache][:connected]
    log.debug "looking for #{string_name} in Legion::Cache"
    cache_result = Legion::Cache.get(string_name)
    return cache_result unless cache_result.nil?
  end

  ENV[string_name] if ENV.key? string_name
  nil
end