Method: Egalite::Handler#initialize

Defined in:
lib/egalite.rb

#initialize(opts = {}) ⇒ Handler

Returns a new instance of Handler.



406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
# File 'lib/egalite.rb', line 406

def initialize(opts = {})
  @routes = opts[:routes] || Route.default_routes
  
  db = opts[:db]
  @db = db
  @opts = opts
  @env = Environment.new(db, opts)
  opts[:static_root] ||= "static/"

  @template_path = opts[:template_path] || 'pages/'
  @template_path << '/' if @template_path[-1..-1] != '/'
  @template_engine = opts[:template_engine] || HTMLTemplate
  
  @profile_logger = opts[:profile_logger]
  @notfound_template = opts[:notfound_template]
  if opts[:error_template_file]
    @error_template = File.open(opts[:error_template_file]).read
  else
    @error_template = opts[:error_template]
  end
  @admin_emails = opts[:admin_emails]
  @email_from = opts[:email_from]
  @exception_log_table = opts[:exception_log_table]
  if @exception_log_table
    Egalite::ErrorLogger.table = db[@exception_log_table]
    Egalite::ErrorLogger.admin_emails = @admin_emails
    Egalite::ErrorLogger.email_from = @email_from
  end
end