Class: I18n::Backend::Http
- Inherits:
-
Object
- Object
- I18n::Backend::Http
- Includes:
- Base
- Defined in:
- lib/i18n/backend/http.rb,
lib/i18n/backend/http/version.rb,
lib/i18n/backend/http/lru_cache.rb,
lib/i18n/backend/http/etag_http_client.rb
Defined Under Namespace
Classes: EtagHttpClient, LRUCache
Constant Summary collapse
- FAILED_GET =
{}.freeze
- VERSION =
Version = "0.3.1"
Instance Method Summary collapse
- #available_locales ⇒ Object
-
#initialize(options) ⇒ Http
constructor
A new instance of Http.
- #stop_polling ⇒ Object
Constructor Details
#initialize(options) ⇒ Http
Returns a new instance of Http.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/i18n/backend/http.rb', line 15 def initialize() = { http_open_timeout: 1, http_read_timeout: 1, polling_interval: 10*60, cache: nil, poll: true, exception_handler: -> (e) { $stderr.puts e }, memory_cache_size: 10, }.merge() @http_client = EtagHttpClient.new() @translations = LRUCache.new([:memory_cache_size]) start_polling if [:poll] end |
Instance Method Details
#available_locales ⇒ Object
31 32 33 |
# File 'lib/i18n/backend/http.rb', line 31 def available_locales @translations.keys.map(&:to_sym).select { |l| l != :i18n } end |
#stop_polling ⇒ Object
35 36 37 |
# File 'lib/i18n/backend/http.rb', line 35 def stop_polling @stop_polling = true end |