Class: SuperSpreader::SpreadTracker

Inherits:
Object
  • Object
show all
Defined in:
lib/super_spreader/spread_tracker.rb

Instance Method Summary collapse

Constructor Details

#initialize(job_class, model_class) ⇒ SpreadTracker

Returns a new instance of SpreadTracker.



8
9
10
11
# File 'lib/super_spreader/spread_tracker.rb', line 8

def initialize(job_class, model_class)
  @job_class = job_class
  @model_class = model_class
end

Instance Method Details

#initial_idObject



13
14
15
16
17
18
19
# File 'lib/super_spreader/spread_tracker.rb', line 13

def initial_id
  redis_value = redis.hget(initial_id_key, @model_class.name)

  value = redis_value || @model_class.maximum(:id)

  value.to_i
end

#initial_id=(value) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/super_spreader/spread_tracker.rb', line 21

def initial_id=(value)
  if value.nil?
    redis.hdel(initial_id_key, @model_class.name)
  else
    redis.hset(initial_id_key, @model_class.name, value)
  end
end