Class: Dizby::TimedIdConverter

Inherits:
Object
  • Object
show all
Defined in:
lib/dizby/converter/timed.rb

Instance Method Summary collapse

Constructor Details

#initialize(timeout = 600_000, step = 30_000) ⇒ TimedIdConverter

default timeout: 10 minutes, default step: 30 seconds


8
9
10
# File 'lib/dizby/converter/timed.rb', line 8

def initialize(timeout = 600_000, step = 30_000)
  @collection = TimedCollection.new(timeout, step)
end

Instance Method Details

#to_id(obj)


17
18
19
20
21
# File 'lib/dizby/converter/timed.rb', line 17

def to_id(obj)
  key = IdConverter.to_id(obj)
  @collection.add(key)
  key
end

#to_obj(ref)


12
13
14
15
# File 'lib/dizby/converter/timed.rb', line 12

def to_obj(ref)
  @collection.revive(ref)
  IdConverter.to_obj(ref)
end