Class: SimpleCaptcha::Middleware

Inherits:
Object
  • Object
show all
Includes:
ImageHelpers
Defined in:
lib/simple_captcha/middleware.rb

Constant Summary collapse

DEFAULT_SEND_FILE_OPTIONS =
{
  :type         => 'application/octet-stream'.freeze,
  :disposition  => 'attachment'.freeze,
}.freeze

Constants included from ImageHelpers

ImageHelpers::DISTORTIONS

Instance Method Summary collapse

Methods included from ImageHelpers

distortion, image_params

Constructor Details

#initialize(app, options = {}) ⇒ Middleware

Returns a new instance of Middleware.



11
12
13
14
# File 'lib/simple_captcha/middleware.rb', line 11

def initialize(app, options={})
  @app = app
  self
end

Instance Method Details

#call(env) ⇒ Object

:nodoc:



16
17
18
19
20
21
22
# File 'lib/simple_captcha/middleware.rb', line 16

def call(env) # :nodoc:
  if env["REQUEST_METHOD"] == "GET" && captcha_path?(env['PATH_INFO'])
    make_image(env)
  else
    @app.call(env)
  end
end