Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit 1b30f23fbaa045c57aea6df23c007be738d973f7 1 parent 6e33e0f
Andre Mendonça authored

Showing 2 changed files with 46 additions and 45 deletions. Show diff stats Hide diff stats

  1. +45 39 lib/drone.js
  2. +1 6 spec/droneModelSpec.js
84 lib/drone.js
@@ -86,14 +86,14 @@ var Drone = {
86 86 }
87 87 };
88 88
89   -Drone.Base = function (classObject) {
90   - return function (attributes) {
  89 +(function (D, $) {
  90 + var base = function (classObject, attributes) {
91 91 var F, requiredAttributes, classObjectClone, instance;
92 92 F = function () {
93   - $.extend(this, Drone.methods(this));
  93 + $.extend(this, D.methods(this));
94 94 };
95 95
96   - requiredAttributes = Drone.helpers.base.getRequiredAttributes(classObject.dependencies, attributes);
  96 + requiredAttributes = D.helpers.base.getRequiredAttributes(classObject.dependencies, attributes);
97 97
98 98 classObjectClone = $.extend(true, {}, classObject);
99 99
@@ -105,50 +105,56 @@ Drone.Base = function (classObject) {
105 105
106 106 return instance;
107 107 };
108   -};
109 108
110   -Drone.View = function (classObject) {
111   - var events = classObject.events || [],
112   - binds = Drone.helpers.views.createEventsBinds(events);
  109 + D.Base = D.Model = function (classObject) {
  110 + return function (attributes) {
  111 + return base(classObject, attributes);
  112 + };
  113 + };
113 114
114   - $.extend(classObject, binds);
  115 + D.View = function (classObject) {
  116 + return function (attributes) {
  117 + var events = classObject.events || [],
  118 + binds = D.helpers.views.createEventsBinds(events);
115 119
116   - delete classObject.events;
117   - return Drone.Base(classObject);
118   -};
  120 + $.extend(classObject, binds);
119 121
120   -Drone.Controller = function (classObject) {
121   - var handlers = classObject.eventHandlers || [],
122   - customInit = classObject.init;
  122 + delete classObject.events;
  123 + return base(classObject, attributes);
  124 + };
  125 + };
123 126
124   - classObject.init = function (attributes) {
125   - Drone.helpers.controllers.bindEventHandlers.call(this, handlers);
  127 + D.Controller = function (classObject) {
  128 + return function (attributes) {
  129 + var handlers = classObject.eventHandlers || [],
  130 + customInit = classObject.init;
126 131
127   - if (customInit) customInit.call(this, attributes);
128   - };
  132 + classObject.init = function (attributes) {
  133 + D.helpers.controllers.bindEventHandlers.call(this, handlers);
129 134
130   - delete classObject.eventHandlers;
131   - return Drone.Base(classObject);
132   -};
  135 + if (customInit) customInit.call(this, attributes);
  136 + };
133 137
134   -Drone.Model = function (classObject) {
135   - return Drone.Base(classObject);
136   -};
  138 + delete classObject.eventHandlers;
  139 + return base(classObject, attributes);
  140 + };
  141 + };
137 142
138   -Drone.Initializer = function (classObject, autoexec) {
139   - classObject.exec = function () {
140   - for (var key in classObject) {
141   - if (classObject.hasOwnProperty(key) && key != "exec" && $.isFunction( classObject[key] )) {
142   - classObject[key]();
  143 + D.Initializer = function (classObject, autoexec) {
  144 + classObject.exec = function () {
  145 + for (var key in classObject) {
  146 + if (classObject.hasOwnProperty(key) && key != "exec" && $.isFunction( classObject[key] )) {
  147 + classObject[key]();
  148 + }
143 149 }
144   - }
145   - };
  150 + };
146 151
147   - if (autoexec === true) {
148   - $().ready(function () {
149   - classObject.exec();
150   - });
151   - }
  152 + if (autoexec === true) {
  153 + $().ready(function () {
  154 + classObject.exec();
  155 + });
  156 + }
152 157
153   - return classObject;
154   -};
  158 + return classObject;
  159 + };
  160 +}(Drone, jQuery));
7 spec/droneModelSpec.js
... ... @@ -1,10 +1,5 @@
1 1 describe("Drone.Model", function () {
2 2 it("should be an alias to Drone.Base", function () {
3   - var modelMock = {attr: "drone"};
4   - spyOn(Drone, "Base").andReturn("drone base");
5   -
6   - var modelInstance = Drone.Model(modelMock);
7   - expect(modelInstance).toEqual("drone base");
8   - expect(Drone.Base).toHaveBeenCalledWith(modelMock);
  3 + expect(Drone.Model).toEqual(Drone.Base);
9 4 });
10 5 });

0 comments on commit 1b30f23

Please sign in to comment.
Something went wrong with that request. Please try again.