Class: Delayed::Master::Database

Inherits:
Object
  • Object
show all
Defined in:
lib/delayed/master/database.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(spec_name) ⇒ Database

Returns a new instance of Database.



11
12
13
# File 'lib/delayed/master/database.rb', line 11

def initialize(spec_name)
  @spec_name = spec_name
end

Instance Attribute Details

#spec_nameObject

Returns the value of attribute spec_name.



9
10
11
# File 'lib/delayed/master/database.rb', line 9

def spec_name
  @spec_name
end

Class Method Details

.all(spec_names = nil) ⇒ Object



44
45
46
47
# File 'lib/delayed/master/database.rb', line 44

def all(spec_names = nil)
  spec_names = spec_names.presence || spec_names_with_delayed_job_table
  spec_names.map { |spec_name| new(spec_name) }
end

Instance Method Details

#modelObject



15
16
17
18
19
# File 'lib/delayed/master/database.rb', line 15

def model
  cache_model do
    define_model
  end
end

#with_connectionObject



21
22
23
24
25
# File 'lib/delayed/master/database.rb', line 21

def with_connection
  model.connection_pool.with_connection do |connection|
    yield connection
  end
end