new_file: don't pass private field to create_open
[ruby-mogilefs-client.git] / lib / mogilefs / util.rb
blob6277497f428b5deb17feaa1137ec0567f11a0f61
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 class MogileFS::Timeout < Timeout::Error; end