Class: WebTranslateIt::AutoFetch
- Inherits:
-
Object
- Object
- WebTranslateIt::AutoFetch
- 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
- #call(env) ⇒ Object
-
#initialize(app) ⇒ AutoFetch
constructor
A new instance of AutoFetch.
Constructor Details
#initialize(app) ⇒ AutoFetch
Returns a new instance of AutoFetch.
15 16 17 |
# File 'lib/web_translate_it/auto_fetch.rb', line 15 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
19 20 21 22 |
# File 'lib/web_translate_it/auto_fetch.rb', line 19 def call(env) update_translations if valid_request?(env) @app.call(env) end |