Class: StrongRoutes::Allow

Inherits:
Object
  • Object
show all
Defined in:
lib/strong_routes/allow.rb

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Allow.



3
4
5
6
# File 'lib/strong_routes/allow.rb', line 3

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

Instance Method Details

#call(env) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/strong_routes/allow.rb', line 8

def call(env)
  return @app.call(env) unless enabled?

  request = ::Rack::Request.new(env)

  if allowed?(request)
    @app.call(env)
  else
    [ 404, { "Content-Type" => "text/html", "Content-Length" => config.message.length.to_s }, [ config.message ] ]
  end
end