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.
12 13 14 |
# File 'lib/web_translate_it/auto_fetch.rb', line 12 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
16 17 18 19 20 |
# File 'lib/web_translate_it/auto_fetch.rb', line 16 def call(env) WebTranslateIt::fetch_translations status, headers, response = @app.call(env) [status, headers, response.body] end |