Class: Operationable::Runners::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/operationable/runners/base.rb

Direct Known Subclasses

Separate, Serial

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(record, params, result, user) ⇒ Base

Returns a new instance of Base.



7
8
9
10
11
12
13
14
15
# File 'lib/operationable/runners/base.rb', line 7

def initialize(record, params, result, user)
  @record = record
  @params = params
  @result = result
  @user = user
  @callbacks = []

  initialize_callbacks
end

Instance Attribute Details

#callbacksObject (readonly)

Returns the value of attribute callbacks.



5
6
7
# File 'lib/operationable/runners/base.rb', line 5

def callbacks
  @callbacks
end

#paramsObject (readonly)

Returns the value of attribute params.



5
6
7
# File 'lib/operationable/runners/base.rb', line 5

def params
  @params
end

#recordObject (readonly)

Returns the value of attribute record.



5
6
7
# File 'lib/operationable/runners/base.rb', line 5

def record
  @record
end

#resultObject (readonly)

Returns the value of attribute result.



5
6
7
# File 'lib/operationable/runners/base.rb', line 5

def result
  @result
end

#userObject (readonly)

Returns the value of attribute user.



5
6
7
# File 'lib/operationable/runners/base.rb', line 5

def user
  @user
end

Instance Method Details

#check_status?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/operationable/runners/base.rb', line 26

def check_status?
  true
end

#ensure_enqueueObject



37
38
39
# File 'lib/operationable/runners/base.rb', line 37

def ensure_enqueue

end

#job_async_execute_methodObject



53
54
55
# File 'lib/operationable/runners/base.rb', line 53

def job_async_execute_method
  :perform_later
end

#job_classObject



45
46
47
# File 'lib/operationable/runners/base.rb', line 45

def job_class
  'OperationJob'
end

#job_methodObject



41
42
43
# File 'lib/operationable/runners/base.rb', line 41

def job_method
  "#{job_class}".constantize.method(perform_method)
end

#job_sync_execute_methodObject



49
50
51
# File 'lib/operationable/runners/base.rb', line 49

def job_sync_execute_method
  :perform_now
end

#persist?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/operationable/runners/base.rb', line 30

def persist?
  true
end

#persist_operationObject



22
23
24
# File 'lib/operationable/runners/base.rb', line 22

def persist_operation
  @persist_operation ||= ::Operationable::Persisters::Database.persist(check_callbacks, user.id, props, operation_class_name)
end

#runObject



34
35
# File 'lib/operationable/runners/base.rb', line 34

def run
end

#store_callback(q_options) ⇒ Object



17
18
19
20
# File 'lib/operationable/runners/base.rb', line 17

def store_callback(q_options)
  op_cb = ::Operationable::Persisters::Database.create(q_options, props)
  q_options.merge({op_cb_id: op_cb.id})  
end