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
# File 'lib/tp_common/timezones/config.rb', line 6

def self.config
  config_list_zones
  config_reversed_list_zones
end

.load_rails_reversed_time_zonesObject



44
45
46
47
48
49
50
51
52
53
# File 'lib/tp_common/timezones/config.rb', line 44

def self.load_rails_reversed_time_zones
  begin
    TpCommon::Timezones.const_set("REVERSED_LIST_ZONES",
                                  reversed_time_zone_lookup_table(Rails.application.config_for(:reversed)))
    return true
  rescue NameError, NoMethodError, StandardError
  end

  false
end

.reversed_time_zone_lookup_table(data_config) ⇒ Object



98
99
100
101
102
103
104
105
106
107
# File 'lib/tp_common/timezones/config.rb', line 98

def self.reversed_time_zone_lookup_table(data_config)
  data_config.inject({}) do |carry, (zone_key, list_zone)|
    zone_key = zone_key.to_sym
    list_zone.each do |zone_name|
      carry[zone_name.downcase.to_sym] = zone_key
    end

    carry
  end
end