Module: JobHunter

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

Constant Summary collapse

VERSION =
'0.1.0'

Instance Method Summary collapse

Instance Method Details

#create(*args) ⇒ Object



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

def create(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  Delayed::Job.enqueue(new(*args), options)
end

#destroy(*args) ⇒ Object



17
18
19
# File 'lib/job_hunter/dj_wrappers.rb', line 17

def destroy(*args)
  find(*args).try(:destroy)
end

#find(*args) ⇒ Object



7
8
9
10
# File 'lib/job_hunter/dj_wrappers.rb', line 7

def find(*args)
  handler = new(*args).to_yaml
  Delayed::Job.where(handler: handler).first
end

#find_or_create(*args) ⇒ Object



12
13
14
15
# File 'lib/job_hunter/dj_wrappers.rb', line 12

def find_or_create(*args)
  job_args = args.last.is_a?(Hash) ? args[0..-2] : args
  find(*job_args) or create(*args)
end