Module: Plugin::Thumbnailer::ImageProcessing

Included in:
Magick::Image
Defined in:
lib/httpthumbnailer/plugin/thumbnailer.rb

Instance Method Summary collapse

Instance Method Details

#replaceObject



60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/httpthumbnailer/plugin/thumbnailer.rb', line 60

def replace
	@use_count ||= 0
	processed = nil
	begin
		processed = yield self
		processed = self unless processed
		fail 'got destroyed image' if processed.destroyed?
	ensure
		self.destroy! if @use_count <= 0 unless processed.equal? self
	end
	processed
end

#useObject



73
74
75
76
77
78
79
80
81
82
83
# File 'lib/httpthumbnailer/plugin/thumbnailer.rb', line 73

def use
	@use_count ||= 0
	@use_count += 1
	begin
		yield self
		self
	ensure
		@use_count -=1
		self.destroy! if @use_count <= 0
	end
end