Class: I18n::Backend::RemoteBackend::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/i18n/backend/remote_backend/loader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(locale = default_locale) ⇒ Loader

Returns a new instance of Loader.



12
13
14
# File 'lib/i18n/backend/remote_backend/loader.rb', line 12

def initialize(locale = default_locale)
  @locale = locale
end

Instance Attribute Details

#localeObject (readonly)

Returns the value of attribute locale.



9
10
11
# File 'lib/i18n/backend/remote_backend/loader.rb', line 9

def locale
  @locale
end

#yamlObject

Returns the value of attribute yaml.



10
11
12
# File 'lib/i18n/backend/remote_backend/loader.rb', line 10

def yaml
  @yaml
end

Instance Method Details

#fetch_localeObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/i18n/backend/remote_backend/loader.rb', line 16

def fetch_locale
  raise RemoteBackend::BlankURLException if RemoteBackend.configuration.http_url.nil?

  begin
    yaml = YAML.safe_load(fetch_remote_file)
    Utils.deep_symbolize_keys(yaml) if yaml.instance_of?(Hash)
  rescue StandardError => e
    RemoteBackend.logger.error "Error occured while reading remote locale : #{RemoteBackend.configuration.http_url}/#{locale} error: " + e.inspect
    nil
  end
end