Class: Locomotive::Middlewares::ImageThumbnail
- Inherits:
-
Object
- Object
- Locomotive::Middlewares::ImageThumbnail
- Defined in:
- lib/locomotive/middlewares/image_thumbnail.rb
Constant Summary collapse
- PATH =
'_image_thumbnail'
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, opts = {}) ⇒ ImageThumbnail
constructor
A new instance of ImageThumbnail.
Constructor Details
#initialize(app, opts = {}) ⇒ ImageThumbnail
Returns a new instance of ImageThumbnail.
7 8 9 |
# File 'lib/locomotive/middlewares/image_thumbnail.rb', line 7 def initialize(app, opts = {}) @app = app end |
Class Method Details
.route ⇒ Object
28 29 30 |
# File 'lib/locomotive/middlewares/image_thumbnail.rb', line 28 def self.route Locomotive.mounted_on + '/' + PATH end |
Instance Method Details
#call(env) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/locomotive/middlewares/image_thumbnail.rb', line 11 def call(env) if env['PATH_INFO'] == self.class.route request = Rack::Request.new(env) image, format = request.params['image'], request.params['format'] if thumb = make_thumb(image, format) respond(thumb) else respond('', 422) end else @app.call(env) end end |