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

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

Instance Method Summary collapse

Methods included from Base

#actor_class, #actor_const, #actor_name, #calling_class, #calling_class_array, #from_json, #full_path, #lex_class, #lex_const, #lex_name, #normalize, #runner_class, #runner_const, #runner_name, #to_dotted_hash

Instance Method Details

#find_setting(name, **opts) ⇒ Object

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



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

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

#settingsObject



8
9
10
11
12
13
14
# File 'lib/legion/extensions/helpers/core.rb', line 8

def settings
  if Legion::Settings[:extensions].key?(lex_filename.to_sym)
    Legion::Settings[:extensions][lex_filename.to_sym]
  else
    { logger: { level: 'info', extended: false, internal: false } }
  end
end