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.



14
15
16
17
18
19
20
21
22
23
# File 'lib/delayed/server.rb', line 14

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

  @allow_update = args.length > 0 && args[0][:update]
end

Instance Method Details

#allow_updateObject



29
30
31
# File 'lib/delayed/server.rb', line 29

def allow_update
  @allow_update
end

#using_active_record?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/delayed/server.rb', line 25

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