Class: Delayed::Server

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/delayed/server.rb,
lib/delayed/server/helpers.rb

Defined Under Namespace

Modules: Helpers

Constant Summary collapse

APP_DIR =
File.dirname(File.expand_path(__FILE__))
DEFAULT_PAGE_SIZE =
10
MAX_PAGE_SIZE =
100

Instance Method Summary collapse

Constructor Details

#initialize(*args, &block) ⇒ Server

Returns a new instance of Server.



12
13
14
15
16
17
18
19
# File 'lib/delayed/server.rb', line 12

def initialize(*args, &block)
  super()
  # Rails will take care of establishing the DB connection for us if there is
  # an application present
  if using_active_record? && !ActiveRecord::Base.connected?
    ActiveRecord::Base.establish_connection(ENV['DATABASE_URL'])
  end
end

Instance Method Details

#using_active_record?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/delayed/server.rb', line 21

def using_active_record?
  Delayed::Job == Delayed::Backend::ActiveRecord::Job
end