Module: ActiveJobStore

Defined in:
lib/active_job_store/version.rb,
lib/active_job_store.rb,
lib/active_job_store/store.rb,
lib/active_job_store/engine.rb,
app/models/active_job_store/record.rb

Overview

:nocov:

Defined Under Namespace

Modules: ClassMethods Classes: Engine, Record, Store

Constant Summary collapse

VERSION =
'0.5.0'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#active_job_store_custom_dataObject

Set / manipulate job’s custom data



8
9
10
# File 'lib/active_job_store.rb', line 8

def active_job_store_custom_data
  @active_job_store_custom_data
end

Class Method Details

.included(base) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/active_job_store.rb', line 51

def included(base)
  base.extend(ClassMethods)

  base.around_enqueue do |job, block|
    store.around_enqueue(job) { block.call }
  end

  base.around_perform do |job, block|
    store.around_perform(job) { block.call }
  end
end

Instance Method Details

#active_job_store_format_result(result) ⇒ any

Format / manipulate / serialize the job result

Parameters:

  • result (any)

    Job’s return value

Returns:

  • (any)

    Processed job’s return value



15
16
17
# File 'lib/active_job_store.rb', line 15

def active_job_store_format_result(result)
  result
end

#active_job_store_internal_error(context, exception) ⇒ Object

Internal errors handler method

Parameters:

  • exception (exception)

    The internal exception



37
38
39
# File 'lib/active_job_store.rb', line 37

def active_job_store_internal_error(context, exception)
  warn("#{context}: #{exception}")
end

#active_job_store_recordActiveJobStore::Record

Return the associated Active Job Store record

Returns:



30
31
32
# File 'lib/active_job_store.rb', line 30

def active_job_store_record
  store.record
end

#save_job_custom_data(custom_data = nil) ⇒ Object

Persist custom data while the job is performing

Parameters:

  • custom_data (any) (defaults to: nil)

    Attributes to serialize (it must be serializable in JSON)



22
23
24
25
# File 'lib/active_job_store.rb', line 22

def save_job_custom_data(custom_data = nil)
  self.active_job_store_custom_data = custom_data if custom_data
  store.update_job_custom_data(active_job_store_custom_data)
end