Class: Rworkflow::SidekiqState

Inherits:
State
  • Object
show all
Defined in:
lib/rworkflow/sidekiq_state.rb

Constant Summary

Constants inherited from State

Rworkflow::State::DEFAULT_CARDINALITY, Rworkflow::State::STATE_POLICY_NO_WAIT, Rworkflow::State::STATE_POLICY_WAIT

Instance Attribute Summary collapse

Attributes inherited from State

#cardinality, #policy, #transitions

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from State

#inspect, #merge, #perform, #serialize, serialize, #to_graph, #transition

Constructor Details

#initialize(worker: nil, **options) ⇒ SidekiqState

Returns a new instance of SidekiqState.



5
6
7
8
# File 'lib/rworkflow/sidekiq_state.rb', line 5

def initialize(worker: nil, **options)
  super(**options)
  @worker_class = worker
end

Instance Attribute Details

#worker_classObject

Returns the value of attribute worker_class.



3
4
5
# File 'lib/rworkflow/sidekiq_state.rb', line 3

def worker_class
  @worker_class
end

Class Method Details

.unserialize(state_hash) ⇒ Object



34
35
36
37
38
39
# File 'lib/rworkflow/sidekiq_state.rb', line 34

def unserialize(state_hash)
  state = super(state_hash)
  state.worker_class = state_hash[:worker_class]

  return state
end

Instance Method Details

#==(other) ⇒ Object



22
23
24
# File 'lib/rworkflow/sidekiq_state.rb', line 22

def ==(other)
  return super && other.worker_class == @worker_class
end

#cloneObject



15
16
17
18
19
20
# File 'lib/rworkflow/sidekiq_state.rb', line 15

def clone
  cloned = super
  cloned.worker_class = @worker_class

  return cloned
end

#merge!(state) ⇒ Object



10
11
12
13
# File 'lib/rworkflow/sidekiq_state.rb', line 10

def merge!(state)
  super
  @worker_class = state.worker_class if state.respond_to?(:worker_class)
end

#to_hObject



26
27
28
29
30
31
# File 'lib/rworkflow/sidekiq_state.rb', line 26

def to_h
  h = super
  h[:worker_class] = @worker_class

  return h
end