wingman_rails 0.0.10 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -383,7 +383,12 @@
383
383
 
384
384
  Model.prototype.destroy = function() {
385
385
  this.trigger('destroy', this);
386
- return this.storageAdapter["delete"](this.get('id'));
386
+ this.storageAdapter["delete"](this.get('id'));
387
+ return this.flush();
388
+ };
389
+
390
+ Model.prototype.flush = function() {
391
+ return this.trigger('flush', this);
387
392
  };
388
393
 
389
394
  Model.prototype.toParam = function() {
@@ -1159,6 +1164,10 @@
1159
1164
  return typeof value === 'object' && ((value != null ? value.constructor : void 0) != null) && value.constructor.name === 'Object' && (!(value instanceof WingmanObject)) && !((value != null ? value._ownerDocument : void 0) != null);
1160
1165
  };
1161
1166
 
1167
+ WingmanObject.prototype.createSubContext = function() {
1168
+ return Object.create(this);
1169
+ };
1170
+
1162
1171
  WingmanObject.prototype.addTriggersToArray = function(propertyName) {
1163
1172
  var array, parent;
1164
1173
  parent = this;
@@ -1206,13 +1215,13 @@
1206
1215
  return this.collections[klass] = new this.collectionClass(klass);
1207
1216
  };
1208
1217
 
1209
- Store.prototype.clear = function() {
1218
+ Store.prototype.flush = function() {
1210
1219
  var collection, klass, _ref, _results;
1211
1220
  _ref = this.collections;
1212
1221
  _results = [];
1213
1222
  for (klass in _ref) {
1214
1223
  collection = _ref[klass];
1215
- _results.push(collection.clear());
1224
+ _results.push(collection.flush());
1216
1225
  }
1217
1226
  return _results;
1218
1227
  };
@@ -1256,7 +1265,7 @@
1256
1265
  Store.prototype.insert = function(model) {
1257
1266
  this.models[model.get('id')] = model;
1258
1267
  this.trigger('add', model);
1259
- return model.bind('destroy', this.remove);
1268
+ return model.bind('flush', this.remove);
1260
1269
  };
1261
1270
 
1262
1271
  Store.prototype.update = function(model, model2) {
@@ -1307,9 +1316,9 @@
1307
1316
  return new Scope(this, params);
1308
1317
  };
1309
1318
 
1310
- Store.prototype.clear = function() {
1319
+ Store.prototype.flush = function() {
1311
1320
  return this.forEach(function(model) {
1312
- return model.destroy();
1321
+ return model.flush();
1313
1322
  });
1314
1323
  };
1315
1324
 
@@ -1790,7 +1799,7 @@
1790
1799
  ForBlockHandler.prototype.add = function(value) {
1791
1800
  var child, hash, key, newContext, _i, _len, _ref, _results;
1792
1801
  this.handlers[value] = [];
1793
- newContext = Object.create(this.context);
1802
+ newContext = this.context.createSubContext();
1794
1803
  key = Fleck.singularize(this.options.source.split('.').pop());
1795
1804
  hash = {};
1796
1805
  hash[key] = value;
@@ -2148,7 +2157,7 @@
2148
2157
 
2149
2158
  }).call(this);
2150
2159
  }, "wingman/view": function(exports, require, module) {(function() {
2151
- var Elementary, Fleck, STYLE_NAMES, Wingman, WingmanObject,
2160
+ var Elementary, Fleck, STYLE_NAMES, View, Wingman, WingmanObject,
2152
2161
  __hasProp = Object.prototype.hasOwnProperty,
2153
2162
  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; },
2154
2163
  __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
@@ -2163,13 +2172,13 @@
2163
2172
 
2164
2173
  STYLE_NAMES = ['backgroundImage', 'backgroundColor', 'backgroundPosition', 'left', 'right', 'top', 'bottom', 'width', 'height'];
2165
2174
 
2166
- module.exports = (function(_super) {
2175
+ module.exports = View = (function(_super) {
2167
2176
 
2168
- __extends(_Class, _super);
2177
+ __extends(View, _super);
2169
2178
 
2170
- _Class.include(Elementary);
2179
+ View.include(Elementary);
2171
2180
 
2172
- _Class.parseEvents = function(eventsHash) {
2181
+ View.parseEvents = function(eventsHash) {
2173
2182
  var key, trigger, _results;
2174
2183
  _results = [];
2175
2184
  for (key in eventsHash) {
@@ -2179,7 +2188,7 @@
2179
2188
  return _results;
2180
2189
  };
2181
2190
 
2182
- _Class.parseEvent = function(key, trigger) {
2191
+ View.parseEvent = function(key, trigger) {
2183
2192
  var type;
2184
2193
  type = key.split(' ')[0];
2185
2194
  return {
@@ -2189,7 +2198,7 @@
2189
2198
  };
2190
2199
  };
2191
2200
 
2192
- function _Class(options) {
2201
+ function View(options) {
2193
2202
  if ((options != null ? options.parent : void 0) != null) {
2194
2203
  this.set({
2195
2204
  parent: options.parent
@@ -2209,17 +2218,17 @@
2209
2218
  this.set({
2210
2219
  children: []
2211
2220
  });
2212
- _Class.__super__.constructor.call(this);
2221
+ View.__super__.constructor.call(this);
2213
2222
  if (options != null ? options.render : void 0) this.render();
2214
2223
  }
2215
2224
 
2216
- _Class.prototype.name = function() {
2225
+ View.prototype.name = function() {
2217
2226
  var withoutView;
2218
2227
  withoutView = this.constructor.name.replace(/View$/, '');
2219
2228
  return Fleck.camelize(Fleck.underscore(withoutView));
2220
2229
  };
2221
2230
 
2222
- _Class.prototype.render = function() {
2231
+ View.prototype.render = function() {
2223
2232
  var template, templateSource;
2224
2233
  templateSource = this.get('templateSource');
2225
2234
  if (templateSource) {
@@ -2232,11 +2241,11 @@
2232
2241
  return typeof this.ready === "function" ? this.ready() : void 0;
2233
2242
  };
2234
2243
 
2235
- _Class.prototype.childClasses = function() {
2244
+ View.prototype.childClasses = function() {
2236
2245
  return this.constructor;
2237
2246
  };
2238
2247
 
2239
- _Class.prototype.createChild = function(name, options) {
2248
+ View.prototype.createChild = function(name, options) {
2240
2249
  var child, className, klass,
2241
2250
  _this = this;
2242
2251
  className = Fleck.camelize(Fleck.underscore(name), true) + 'View';
@@ -2260,7 +2269,7 @@
2260
2269
  return child;
2261
2270
  };
2262
2271
 
2263
- _Class.prototype.templateSource = function() {
2272
+ View.prototype.templateSource = function() {
2264
2273
  var name, templateSource;
2265
2274
  name = this.get('templateName');
2266
2275
  templateSource = this.constructor.templateSources[name];
@@ -2268,11 +2277,11 @@
2268
2277
  return templateSource;
2269
2278
  };
2270
2279
 
2271
- _Class.prototype.templateName = function() {
2280
+ View.prototype.templateName = function() {
2272
2281
  return this.path();
2273
2282
  };
2274
2283
 
2275
- _Class.prototype.setupListeners = function() {
2284
+ View.prototype.setupListeners = function() {
2276
2285
  var _this = this;
2277
2286
  this.el.addEventListener('click', function(e) {
2278
2287
  if (_this.click) return _this.click(e);
@@ -2280,7 +2289,7 @@
2280
2289
  if (this.events) return this.setupEvents();
2281
2290
  };
2282
2291
 
2283
- _Class.prototype.setupEvents = function() {
2292
+ View.prototype.setupEvents = function() {
2284
2293
  var event, _i, _len, _ref, _results;
2285
2294
  _ref = this.constructor.parseEvents(this.events);
2286
2295
  _results = [];
@@ -2291,7 +2300,7 @@
2291
2300
  return _results;
2292
2301
  };
2293
2302
 
2294
- _Class.prototype.triggerWithCustomArguments = function(trigger) {
2303
+ View.prototype.triggerWithCustomArguments = function(trigger) {
2295
2304
  var args, argumentsMethodName, customArguments;
2296
2305
  args = [trigger];
2297
2306
  argumentsMethodName = Fleck.camelize(trigger) + "Arguments";
@@ -2300,7 +2309,7 @@
2300
2309
  return this.trigger.apply(this, args);
2301
2310
  };
2302
2311
 
2303
- _Class.prototype.setupEvent = function(event) {
2312
+ View.prototype.setupEvent = function(event) {
2304
2313
  var _this = this;
2305
2314
  return this.el.addEventListener(event.type, function(e) {
2306
2315
  var current, elm, match, _i, _len, _ref, _results;
@@ -2324,15 +2333,15 @@
2324
2333
  });
2325
2334
  };
2326
2335
 
2327
- _Class.prototype.pathName = function() {
2336
+ View.prototype.pathName = function() {
2328
2337
  return Fleck.underscore(this.constructor.name.replace(/([A-Z])/g, ' $1').substring(1).split(' ').slice(0, -1).join(''));
2329
2338
  };
2330
2339
 
2331
- _Class.prototype.append = function(view) {
2340
+ View.prototype.append = function(view) {
2332
2341
  return this.el.appendChild(view.el);
2333
2342
  };
2334
2343
 
2335
- _Class.prototype.pathKeys = function() {
2344
+ View.prototype.pathKeys = function() {
2336
2345
  var pathKeys, _ref;
2337
2346
  if (this.isRoot()) return [];
2338
2347
  pathKeys = [this.pathName()];
@@ -2342,11 +2351,11 @@
2342
2351
  return pathKeys;
2343
2352
  };
2344
2353
 
2345
- _Class.prototype.isRoot = function() {
2354
+ View.prototype.isRoot = function() {
2346
2355
  return this.get('parent') instanceof Wingman.Application;
2347
2356
  };
2348
2357
 
2349
- _Class.prototype.path = function() {
2358
+ View.prototype.path = function() {
2350
2359
  if (this.get('parent') instanceof Wingman.Application) {
2351
2360
  return 'root';
2352
2361
  } else {
@@ -2354,12 +2363,12 @@
2354
2363
  }
2355
2364
  };
2356
2365
 
2357
- _Class.prototype.remove = function() {
2366
+ View.prototype.remove = function() {
2358
2367
  if (this.el.parentNode) Elementary.remove.call(this);
2359
2368
  return this.trigger('remove');
2360
2369
  };
2361
2370
 
2362
- _Class.prototype.setupStyles = function() {
2371
+ View.prototype.setupStyles = function() {
2363
2372
  var name, property, _results;
2364
2373
  _results = [];
2365
2374
  for (name in this) {
@@ -2373,7 +2382,7 @@
2373
2382
  return _results;
2374
2383
  };
2375
2384
 
2376
- _Class.prototype.setupStyle = function(name) {
2385
+ View.prototype.setupStyle = function(name) {
2377
2386
  var _this = this;
2378
2387
  this.setStyle(name, this.get(name));
2379
2388
  return this.observe(name, function(newValue) {
@@ -2381,7 +2390,17 @@
2381
2390
  });
2382
2391
  };
2383
2392
 
2384
- return _Class;
2393
+ View.prototype.createSubContext = function() {
2394
+ var context,
2395
+ _this = this;
2396
+ context = View.__super__.createSubContext.call(this);
2397
+ context.bind('descendantCreated', function(child) {
2398
+ return _this.trigger('descendantCreated', child);
2399
+ });
2400
+ return context;
2401
+ };
2402
+
2403
+ return View;
2385
2404
 
2386
2405
  })(WingmanObject);
2387
2406
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wingman_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-04-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
16
- requirement: &70186217504960 !ruby/object:Gem::Requirement
16
+ requirement: &70146552251740 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -24,7 +24,7 @@ dependencies:
24
24
  version: '5.0'
25
25
  type: :runtime
26
26
  prerelease: false
27
- version_requirements: *70186217504960
27
+ version_requirements: *70146552251740
28
28
  description: This gem provides Wingman for your Rails 3 application.
29
29
  email:
30
30
  - rasmusrnielsen@gmail.com