Permalink
Browse files

Base class become private, but we maintained Drone.Base as a deprecat…

…ed alias. We intend to remove it in the future.
  • Loading branch information...
1 parent 6e33e0f commit 1b30f23fbaa045c57aea6df23c007be738d973f7 Andre Mendonça committed Apr 24, 2012
Showing with 46 additions and 45 deletions.
  1. +45 −39 lib/drone.js
  2. +1 −6 spec/droneModelSpec.js
View
84 lib/drone.js
@@ -86,14 +86,14 @@ var Drone = {
}
};
-Drone.Base = function (classObject) {
- return function (attributes) {
+(function (D, $) {
+ var base = function (classObject, attributes) {
var F, requiredAttributes, classObjectClone, instance;
F = function () {
- $.extend(this, Drone.methods(this));
+ $.extend(this, D.methods(this));
};
- requiredAttributes = Drone.helpers.base.getRequiredAttributes(classObject.dependencies, attributes);
+ requiredAttributes = D.helpers.base.getRequiredAttributes(classObject.dependencies, attributes);
classObjectClone = $.extend(true, {}, classObject);
@@ -105,50 +105,56 @@ Drone.Base = function (classObject) {
return instance;
};
-};
-Drone.View = function (classObject) {
- var events = classObject.events || [],
- binds = Drone.helpers.views.createEventsBinds(events);
+ D.Base = D.Model = function (classObject) {
+ return function (attributes) {
+ return base(classObject, attributes);
+ };
+ };
- $.extend(classObject, binds);
+ D.View = function (classObject) {
+ return function (attributes) {
+ var events = classObject.events || [],
+ binds = D.helpers.views.createEventsBinds(events);
- delete classObject.events;
- return Drone.Base(classObject);
-};
+ $.extend(classObject, binds);
-Drone.Controller = function (classObject) {
- var handlers = classObject.eventHandlers || [],
- customInit = classObject.init;
+ delete classObject.events;
+ return base(classObject, attributes);
+ };
+ };
- classObject.init = function (attributes) {
- Drone.helpers.controllers.bindEventHandlers.call(this, handlers);
+ D.Controller = function (classObject) {
+ return function (attributes) {
+ var handlers = classObject.eventHandlers || [],
+ customInit = classObject.init;
- if (customInit) customInit.call(this, attributes);
- };
+ classObject.init = function (attributes) {
+ D.helpers.controllers.bindEventHandlers.call(this, handlers);
- delete classObject.eventHandlers;
- return Drone.Base(classObject);
-};
+ if (customInit) customInit.call(this, attributes);
+ };
-Drone.Model = function (classObject) {
- return Drone.Base(classObject);
-};
+ delete classObject.eventHandlers;
+ return base(classObject, attributes);
+ };
+ };
-Drone.Initializer = function (classObject, autoexec) {
- classObject.exec = function () {
- for (var key in classObject) {
- if (classObject.hasOwnProperty(key) && key != "exec" && $.isFunction( classObject[key] )) {
- classObject[key]();
+ D.Initializer = function (classObject, autoexec) {
+ classObject.exec = function () {
+ for (var key in classObject) {
+ if (classObject.hasOwnProperty(key) && key != "exec" && $.isFunction( classObject[key] )) {
+ classObject[key]();
+ }
}
- }
- };
+ };
- if (autoexec === true) {
- $().ready(function () {
- classObject.exec();
- });
- }
+ if (autoexec === true) {
+ $().ready(function () {
+ classObject.exec();
+ });
+ }
- return classObject;
-};
+ return classObject;
+ };
+}(Drone, jQuery));
View
7 spec/droneModelSpec.js
@@ -1,10 +1,5 @@
describe("Drone.Model", function () {
it("should be an alias to Drone.Base", function () {
- var modelMock = {attr: "drone"};
- spyOn(Drone, "Base").andReturn("drone base");
-
- var modelInstance = Drone.Model(modelMock);
- expect(modelInstance).toEqual("drone base");
- expect(Drone.Base).toHaveBeenCalledWith(modelMock);
+ expect(Drone.Model).toEqual(Drone.Base);
});
});

0 comments on commit 1b30f23

Please sign in to comment.