Class: Rack::BetaSite

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/bacchus/rack/beta_site.rb

Defined Under Namespace

Classes: Request

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of BetaSite.



19
20
21
22
23
24
25
# File 'lib/bacchus/rack/beta_site.rb', line 19

def initialize(app, options = {})
  @app = app
  @excluded_routes = options[:except] || []
  @access_form_routes = options[:access_through] || []
  @access_template_route = options[:access_template] or raise "Specify the route to the template for the access form."
  @server = options[:server] or raise "Specify the address of the server."
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



17
18
19
# File 'lib/bacchus/rack/beta_site.rb', line 17

def options
  @options
end

Instance Method Details

#call(env) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/bacchus/rack/beta_site.rb', line 27

def call(env)
  request = Request.new(env)
  if access_form_route?(request)
    request.path = @access_template_route
    env["PATH_INFO"]        = request.path
    env["REQUEST_URI"]      = request.fullpath
    render_with_bacchus(env)
  elsif access_denied?(request)
    render_locked
  else
    @app.call(env)
  end  
end