Class: WebTranslateIt::AutoFetch

Inherits:
Object
  • Object
show all
Defined in:
lib/web_translate_it/auto_fetch.rb

Overview

Class to automatically fetch the last translations from Web Translate It for every page requested. This can be used as a rack middleware. Implementation example:

# in config/environment.rb:
config.middleware.use "WebTranslateIt::AutoFetch"

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ AutoFetch

Returns a new instance of AutoFetch



13
14
15
# File 'lib/web_translate_it/auto_fetch.rb', line 13

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



17
18
19
20
# File 'lib/web_translate_it/auto_fetch.rb', line 17

def call(env)
  update_translations if valid_request?(env)
  @app.call(env)
end