Module: JobHunter

Defined in:
lib/job_hunter/version.rb,
lib/job_hunter/defaults.rb,
lib/job_hunter/dj_wrappers.rb

Defined Under Namespace

Modules: InstanceMethods

Constant Summary collapse

VERSION =
'0.3.0'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base_class) ⇒ Object


2
3
4
# File 'lib/job_hunter/dj_wrappers.rb', line 2

def self.extended(base_class)
  base_class.include(InstanceMethods)
end

Instance Method Details

#_defaults_Object


18
19
20
21
22
# File 'lib/job_hunter/defaults.rb', line 18

def _defaults_
  { priority: @priority, 
    run_at:   @run_at.try(:call),
    queue:    @queue }.select { |k, v| v }
end

#max_attempts(value) ⇒ Object


14
15
16
# File 'lib/job_hunter/defaults.rb', line 14

def max_attempts(value)
  define_method(:max_attempts) { value }
end

#new_with_options(*args) ⇒ Object


39
40
41
42
43
44
45
46
# File 'lib/job_hunter/dj_wrappers.rb', line 39

def new_with_options(*args)
  options = args.extract_options!
  job = new(*args)
  job.define_singleton_method(:_options_) do
    self.class._defaults_.merge(options)
  end
  job
end

#priority(pri) ⇒ Object


6
7
8
# File 'lib/job_hunter/defaults.rb', line 6

def priority(pri)
  @priority = pri
end

#queue(queue) ⇒ Object


10
11
12
# File 'lib/job_hunter/defaults.rb', line 10

def queue(queue)
  @queue = queue
end

#run_at(proc) ⇒ Object


2
3
4
# File 'lib/job_hunter/defaults.rb', line 2

def run_at(proc)
  @run_at = proc
end