Class: TpCommon::Timezones::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/tp_common/timezones/config.rb

Class Method Summary collapse

Class Method Details

.configObject

Try to load TpCommon::Timezones::LIST_ZONES in config/timezones.yml from rails app. if not, load the default in timezones/config/timezones.yml


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/tp_common/timezones/config.rb', line 6

def self.config
  return if TpCommon::Timezones.const_defined?("LIST_ZONES")
  if defined?(::Rails::Railtie)
    begin
      TpCommon::Timezones.const_set("LIST_ZONES", Rails.application.config_for(:timezones))
      puts "[TpCommon::Timezones::Config] Message-3: Use custom timezones in project config/timezones.yml"
      return
    rescue NameError, NoMethodError
      puts "[TpCommon::Timezones::Config] Message-1: Use default timezones in tp_common/timezones/config/timezones.yml"
    rescue StandardError
      puts "[TpCommon::Timezones::Config] Message-2: Use default timezones in tp_common/timezones/config/timezones.yml"
    end
  end

  TpCommon::Timezones.const_set("LIST_ZONES", load_default_timezones)
end