Module: Tasque

Defined in:
lib/tasque.rb,
lib/tasque/task.rb,
lib/tasque/version.rb,
lib/tasque/processor.rb,
lib/tasque/task_error.rb,
lib/tasque/task_cancel.rb,
lib/tasque/configuration.rb,
lib/generators/tasque/install_generator.rb

Defined Under Namespace

Classes: Configuration, InstallGenerator, Processor, Task, TaskCancel, TaskError

Constant Summary collapse

VERSION =
"0.2.3"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configObject

Returns the value of attribute config.



5
6
7
# File 'lib/tasque/configuration.rb', line 5

def config
  @config
end

Class Method Details

.configure {|config| ... } ⇒ Object

Yields:



8
9
10
11
12
13
# File 'lib/tasque/configuration.rb', line 8

def self.configure
  self.config ||= Configuration.new
  yield(config) if block_given?
  self.database_connection
  return self.config
end

.database_connectionObject



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/tasque/configuration.rb', line 15

def self.database_connection()
  raise 'No configuration. Use Tasque.configure' if self.config.nil?
  @database ||= begin
    if !defined?(Rails) && !ActiveRecord::Base.connected?
      ActiveRecord::Base.logger = self.config.logger
      db = self.config.database[self.config.environment.to_s]
      db = self.config.database if db.nil?
      ActiveRecord::Base.establish_connection(db)
      ActiveRecord::Base.connection
    end
    ActiveRecord::Base
  end
end

.rootObject



29
30
31
# File 'lib/tasque/configuration.rb', line 29

def self.root
  defined?(TASQUE_ROOT) ? TASQUE_ROOT : Dir.pwd
end