about summary refs log tree commit homepage
path: root/lib/mogilefs/mogilefs.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mogilefs/mogilefs.rb')
-rw-r--r--lib/mogilefs/mogilefs.rb32
1 files changed, 23 insertions, 9 deletions
diff --git a/lib/mogilefs/mogilefs.rb b/lib/mogilefs/mogilefs.rb
index b192605..8a35168 100644
--- a/lib/mogilefs/mogilefs.rb
+++ b/lib/mogilefs/mogilefs.rb
@@ -125,16 +125,30 @@ class MogileFS::MogileFS < MogileFS::Client
     get_paths(key, *args).map! { |path| URI.parse(path) }
   end
 
-  # Creates a new file +key+ in +klass+.  +bytes+ is currently unused.
-  # Consider using store_file instead of this method for large files.
-  # This requires a block passed to it and operates like File.open.
-  # This atomically replaces existing data stored as +key+ when
+  # Creates a new file +key+ in the domain of this object.
+  #
+  # +bytes+ is the expected size of the file if known in advance
+  #
+  # It operates like File.open(..., "w") and may take an optional
+  # block, yielding an IO-like object with support for the methods
+  # documented in MogileFS::NewFile::Writer.
+  #
+  # This atomically replaces existing data stored as +key+
+  # when the block exits or when the returned object is closed.
   #
   # +args+ may contain the following options:
-  # * :content_length => Integer
-  # * :largefile => [ :stream, :content_range, :tempfile ]
-  #    (see # MogileFS::NewFile)
-  # * :content_md5 => String, Proc, or :trailer
+  #
+  # [:content_length => Integer]
+  #
+  #   This has the same effect as the (deprecated) +bytes+ parameter.
+  #
+  # [ :largefile => :stream, :content_range or :tempfile ]
+  #
+  #   See MogileFS::NewFile for more information on this
+  #
+  # [ :class => String]
+  #
+  #   The MogileFS storage class of the object.
   def new_file(key, args = nil, bytes = nil) # :yields: file
     raise MogileFS::ReadOnlyError if readonly?
     opts = { :key => key, :multi_dest => 1 }
@@ -167,7 +181,7 @@ class MogileFS::MogileFS < MogileFS::Client
 
     case (dests[0][1] rescue nil)
     when %r{\Ahttp://}
-      http_file = MogileFS::NewFile[opts[:largefile]].new(dests, opts)
+      http_file = MogileFS::NewFile.new(dests, opts)
       if block_given?
         yield http_file
         return http_file.commit # calls create_close