Permalink
Browse files

added more documentatiooonnnn

  • Loading branch information...
1 parent b973e10 commit 858b956ead24db6f117f8362b078f8095bd40a42 @partkyle partkyle committed Feb 11, 2012
Showing with 23 additions and 1 deletion.
  1. +23 −1 lib/file_handler.js
View
24 lib/file_handler.js
@@ -5,6 +5,18 @@ var _ = require('underscore');
var url = require('url');
var fs = require('fs');
+/**
+ * Class to handle file attachments on an email.
+ *
+ * @param {object} file_object Options to create a FileHandler
+ * @param {string} filename The name of the file to send.
+ * This will be guessed based on the file added
+ * if blank.
+ * @param {string} contentType The Content-Type of the file.
+ * @param {string} content The content to send in the file (usually a Buffer)
+ * @param {string} path The absolute path of the file on the filesystem
+ * @param {string} url The url to fetch a file from before sending
+ */
function FileHandler(file_object) {
this.filename = file_object.filename;
@@ -33,12 +45,15 @@ function FileHandler(file_object) {
if (!this.contentType) {
this.contentType = mime.lookup(this.url);
}
- } else {this
+ } else {
this.type = 'none';
this.contentType = 'none';
}
}
+/**
+ * The different methods of loading a file based on the type
+ */
FileHandler.handlers = {
content: function(file, callback) {
if (file.content) {
@@ -95,6 +110,13 @@ FileHandler.handlers = {
}
};
+/**
+ * Loads the content of the file based on the type
+ * and calls a callback when finished.
+ *
+ * @param {function} callback A function to call when
+ * the result is finished.
+ */
FileHandler.prototype.loadContent = function(callback) {
var handler = FileHandler.handlers[this.type];
if (handler) {

0 comments on commit 858b956

Please sign in to comment.