Module: WorkersLoader
- Defined in:
- lib/workers_loader.rb,
lib/workers_loader/path.rb,
lib/workers_loader/version.rb
Overview
Resque workers strategy loading system
Defined Under Namespace
Classes: Path
Constant Summary collapse
- VERSION =
'0.0.4'- @@workers_paths =
[]
- @@workers =
[]
- @@resque_mailer =
false
Class Method Summary collapse
- .add_path(path, parent = true) ⇒ Object
- .load_workers! ⇒ Object
- .resque_mailer! ⇒ Object
- .resque_mailer? ⇒ Boolean
- .resque_mailer_install ⇒ Object
Class Method Details
.add_path(path, parent = true) ⇒ Object
17 18 19 20 |
# File 'lib/workers_loader.rb', line 17 def add_path(path, parent = true) fail "Directory not found: `#{path}`" unless Dir.exist?(path) @@workers_paths << Path.new(path, parent) end |
.load_workers! ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/workers_loader.rb', line 22 def load_workers! workers_paths.each do |path| workers_in_path = path.find next if workers_in_path.empty? duplacates = workers_in_path .select { |worker| workers.include?(worker) } .sort.join(', ') fail("Workers already present! #{duplacates}") unless duplacates.blank? self.workers += workers_in_path end resque_mailer_install end |
.resque_mailer! ⇒ Object
43 44 45 |
# File 'lib/workers_loader.rb', line 43 def resque_mailer! @@resque_mailer = true end |
.resque_mailer? ⇒ Boolean
47 48 49 |
# File 'lib/workers_loader.rb', line 47 def resque_mailer? @@resque_mailer end |
.resque_mailer_install ⇒ Object
38 39 40 41 |
# File 'lib/workers_loader.rb', line 38 def resque_mailer_install return if !resque_mailer? || self.workers.include?(:mailer) self.workers << :mailer end |