Class: DeepStore::Sweeper

Inherits:
Object
  • Object
show all
Defined in:
lib/deep_store/sweeper.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stream) ⇒ Sweeper

Returns a new instance of Sweeper.



11
12
13
# File 'lib/deep_store/sweeper.rb', line 11

def initialize(stream)
  @stream = stream
end

Instance Attribute Details

#streamObject (readonly)

Returns the value of attribute stream.



3
4
5
# File 'lib/deep_store/sweeper.rb', line 3

def stream
  @stream
end

Class Method Details

.register(object, stream) ⇒ Object



5
6
7
8
9
# File 'lib/deep_store/sweeper.rb', line 5

def self.register(object, stream)
  sweeper = Sweeper.new(stream)
  ObjectSpace.define_finalizer(object, sweeper)
  sweeper
end

Instance Method Details

#call(_object_id) ⇒ Object



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

def call(_object_id)
  finalize
end

#finalizeObject



19
20
21
22
# File 'lib/deep_store/sweeper.rb', line 19

def finalize
  stream.close if stream.respond_to?(:close)
  stream.unlink if stream.respond_to?(:unlink)
end