should be wrapped correctly this time:

var Class = {
  create: function() {

    var parent = null, properties = $A(arguments);

    // retrieve the class name
    var className = "";
    if(Object.isString(properties[0])) {
                className = properties.shift();
    }

        // get the parent
    if (Object.isFunction(properties[0]))
      parent = properties.shift();

    function klass() {
                this.initialize.apply(this, arguments);
    }

    Object.extend(klass, Class.Methods);
    klass.superclass = parent;
    klass.subclasses = [];

    // reference the class by name
        if(className!="") {
                window[className] = klass;
    }

    // store the classname as klass.constructor.className
    // and add a method getClassName() to all classes
    klass.className = className;
        klass.prototype.constructor.addMethods({
                getClassName: function() {
                        return this.constructor.className;
                }
        });

    if (parent) {
      var subclass = function() { };
      subclass.prototype = parent.prototype;
      klass.prototype = new subclass;
      parent.subclasses.push(klass);
    }

    for (var i = 0; i < properties.length; i++)
      klass.addMethods(properties[i]);

    if (!klass.prototype.initialize)
      klass.prototype.initialize = Prototype.emptyFunction;

    klass.prototype.constructor = klass;

    return klass;
  }
};
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to