avoid defineclass instructions for empty classes
[ruby-mogilefs-client.git] / lib / mogilefs / util.rb
blobad4845d976709347a02b5d74c4f8902e51241dd3
1 # -*- encoding: binary -*-
3 module MogileFS::Util
5   # MogileFS::Util::StoreContent allows you to roll your own method
6   # of streaming data on an upload (instead of using a string or file)
7   #
8   # Current versions of this library support streaming a IO or IO-like
9   # object to using MogileFS::MogileFS#store_file, so using StoreContent
10   # may no longer be necessary.
11   class StoreContent < Proc
12     def initialize(total_size, &writer_proc)
13       @total_size = total_size
14       super(&writer_proc)
15     end
16     def length
17       @total_size
18     end
19   end
20 end
22 require 'timeout'
24 # Timeout error class.  Subclassing it from Timeout::Error is the only
25 # reason we require the 'timeout' module, otherwise that module is
26 # broken and worthless to us.
27 MogileFS::Timeout = Class.new(Timeout::Error)