]> git.openstreetmap.org Git - rails.git/blobdiff - vendor/plugins/file_column/lib/file_compat.rb
Updating to use Rails 2.1.2. Moving the gem dependancies to the config/environment...
[rails.git] / vendor / plugins / file_column / lib / file_compat.rb
diff --git a/vendor/plugins/file_column/lib/file_compat.rb b/vendor/plugins/file_column/lib/file_compat.rb
new file mode 100644 (file)
index 0000000..f284410
--- /dev/null
@@ -0,0 +1,28 @@
+module FileColumn
+
+  # This bit of code allows you to pass regular old files to
+  # file_column.  file_column depends on a few extra methods that the
+  # CGI uploaded file class adds.  We will add the equivalent methods
+  # to file objects if necessary by extending them with this module. This
+  # avoids opening up the standard File class which might result in
+  # naming conflicts.
+
+  module FileCompat # :nodoc:
+    def original_filename
+      File.basename(path)
+    end
+    
+    def size
+      File.size(path)
+    end
+    
+    def local_path
+      path
+    end
+    
+    def content_type
+      nil
+    end
+  end
+end
+