joosy 1.2.0.alpha.58 → 1.2.0.alpha.59

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 877691f0d3fe49b4f115f111663aba62396a0421
4
- data.tar.gz: 7996ed76d2bddc7349b6ec2d316ee0a7ab4c1883
3
+ metadata.gz: bca3233835310754afca28be9330ec70a839b55e
4
+ data.tar.gz: fcd2fbff79196181a4f6babbf812d84ee5778ec0
5
5
  SHA512:
6
- metadata.gz: 5b169f311b2a03478e24b1be422843e2ceb4786c4389217029f04b10e7a8245a0b6b156295cd1cdfae2486cd17d0c5b26a3a99c307b09d6dd5d251c1072d36d6
7
- data.tar.gz: 673c4f423886679626cf29d4255bba23aba634aeca135358243b9e9b7efacfb4c3d5d37a9c6b3882b67f8dc0454f69e03b596a1820e177c832764d5b23b1ccd6
6
+ metadata.gz: ba8c3caae6da6816987fcab5008ed02fb6a3a62c99accf8af987a15ab564a1afbbe0bae233777a405fabc87c2dd07d777f81fa486ec6f087139095e11d9f7044
7
+ data.tar.gz: 78f4d74388d85d3ae2cb05c88061cea9e153fa5edfb1d85c6538e081aaf098d845f4f5354dd01e3896df0c4b8c0cfed1101d2c2348d61938feaa2217d89017d7
data/bower.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "joosy",
3
- "version": "1.2.0-alpha.58",
3
+ "version": "1.2.0-alpha.59",
4
4
  "main": "lib/joosy.js",
5
5
  "ignore": [
6
6
  "bin",
@@ -266,6 +266,9 @@
266
266
  var result,
267
267
  _this = this;
268
268
  result = {};
269
+ if (Object.isObject(errors != null ? errors.errors : void 0)) {
270
+ errors = errors.errors;
271
+ }
269
272
  Object.each(errors, function(field, notifications) {
270
273
  var f, name, splited, _i, _len;
271
274
  if (_this.substitutions[field] != null) {
@@ -11,8 +11,6 @@
11
11
 
12
12
  Base.prototype.__primaryKey = 'id';
13
13
 
14
- Base.prototype.__source = false;
15
-
16
14
  Base.resetIdentity = function() {
17
15
  return Joosy.Resources.Base.identity = {};
18
16
  };
@@ -67,26 +65,14 @@
67
65
  };
68
66
 
69
67
  Base.build = function(data) {
70
- var id, key, klass, shim, value, _base, _base1, _ref;
68
+ var id, klass, shim, _base, _base1;
71
69
  if (data == null) {
72
70
  data = {};
73
71
  }
74
72
  klass = this.prototype.__entityName;
75
73
  (_base = Joosy.Resources.Base).identity || (_base.identity = {});
76
74
  (_base1 = Joosy.Resources.Base.identity)[klass] || (_base1[klass] = {});
77
- shim = function() {
78
- return shim.__call.apply(shim, arguments);
79
- };
80
- if (shim.__proto__) {
81
- shim.__proto__ = this.prototype;
82
- } else {
83
- _ref = this.prototype;
84
- for (key in _ref) {
85
- value = _ref[key];
86
- shim[key] = value;
87
- }
88
- }
89
- shim.constructor = this;
75
+ shim = this.__makeShim(this.prototype);
90
76
  if (Object.isNumber(data) || Object.isString(data)) {
91
77
  id = data;
92
78
  data = {};
@@ -107,6 +93,23 @@
107
93
  return shim;
108
94
  };
109
95
 
96
+ Base.__makeShim = function(proto) {
97
+ var key, shim, value;
98
+ shim = function() {
99
+ return shim.__call.apply(shim, arguments);
100
+ };
101
+ if (shim.__proto__) {
102
+ shim.__proto__ = proto;
103
+ } else {
104
+ for (key in proto) {
105
+ value = proto[key];
106
+ shim[key] = value;
107
+ }
108
+ }
109
+ shim.constructor = this;
110
+ return shim;
111
+ };
112
+
110
113
  function Base(data) {
111
114
  if (data == null) {
112
115
  data = {};
@@ -115,7 +118,8 @@
115
118
  }
116
119
 
117
120
  Base.prototype.id = function() {
118
- return this.data[this.__primaryKey];
121
+ var _ref;
122
+ return (_ref = this.data) != null ? _ref[this.__primaryKey] : void 0;
119
123
  };
120
124
 
121
125
  Base.prototype.knownAttributes = function() {
@@ -385,31 +389,51 @@
385
389
  return this.__source = location;
386
390
  };
387
391
 
392
+ REST.__atWrapper = function() {
393
+ var args, definer,
394
+ _this = this;
395
+ definer = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
396
+ if (args.length === 1 && Object.isArray(args[0])) {
397
+ return this.__atWrapper.apply(this, [definer].concat(__slice.call(args[0])));
398
+ } else {
399
+ return definer(function(clone) {
400
+ clone.__source = args.reduce(function(path, arg) {
401
+ return path += arg instanceof Joosy.Resources.REST ? arg.memberPath() : arg.replace(/^\/?/, '/');
402
+ }, '');
403
+ return clone.__source += '/' + _this.prototype.__entityName.pluralize();
404
+ });
405
+ }
406
+ };
407
+
388
408
  REST.at = function() {
389
- var Clone, args, _ref1;
409
+ var args,
410
+ _this = this;
390
411
  args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
391
- Clone = (function(_super1) {
392
- __extends(Clone, _super1);
412
+ return this.__atWrapper.apply(this, [function(callback) {
413
+ var Clone, _ref1;
414
+ return Clone = (function(_super1) {
415
+ __extends(Clone, _super1);
416
+
417
+ function Clone() {
418
+ _ref1 = Clone.__super__.constructor.apply(this, arguments);
419
+ return _ref1;
420
+ }
393
421
 
394
- function Clone() {
395
- _ref1 = Clone.__super__.constructor.apply(this, arguments);
396
- return _ref1;
397
- }
422
+ callback(Clone);
398
423
 
399
- return Clone;
424
+ return Clone;
400
425
 
401
- })(this);
402
- if (args.length === 1 && Object.isArray(args[0])) {
403
- return this.at.apply(this, args[0]);
404
- } else {
405
- Clone.__source = args.reduce(function(path, arg) {
406
- return path += arg instanceof Joosy.Resources.Base ? arg.memberPath() : arg.replace(/^\/?/, '/');
407
- }, '');
408
- if (this.prototype.__entityName && args[args.length - 1] instanceof Joosy.Resources.Base) {
409
- Clone.__source += '/' + this.prototype.__entityName.pluralize();
410
- }
411
- return Clone;
412
- }
426
+ })(_this);
427
+ }].concat(__slice.call(args)));
428
+ };
429
+
430
+ REST.prototype.at = function() {
431
+ var args, _ref1,
432
+ _this = this;
433
+ args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
434
+ return (_ref1 = this.constructor).__atWrapper.apply(_ref1, [function(callback) {
435
+ return Object.tap(_this.constructor.__makeShim(_this), callback);
436
+ }].concat(__slice.call(args)));
413
437
  };
414
438
 
415
439
  REST.prototype.__collection = function() {
@@ -422,57 +446,83 @@
422
446
  }
423
447
  };
424
448
 
425
- REST.__parentsPath = function(parents) {
426
- return parents.reduce(function(path, parent) {
427
- return path += Joosy.Module.hasAncestor(parent.constructor, Joosy.Resources.REST) ? parent.memberPath() : parent;
428
- }, '');
449
+ REST.prototype.__interpolatePath = function(source, ids) {
450
+ if (!Object.isArray(ids)) {
451
+ ids = [ids];
452
+ }
453
+ return ids.reduce(function(path, id) {
454
+ if (id instanceof Joosy.Resources.REST) {
455
+ id = id.id();
456
+ }
457
+ return path.replace(/:[^\/]+/, id);
458
+ }, source);
459
+ };
460
+
461
+ REST.collectionPath = function() {
462
+ var args, _ref1;
463
+ args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
464
+ return (_ref1 = this.prototype).collectionPath.apply(_ref1, args);
429
465
  };
430
466
 
431
- REST.collectionPath = function(options) {
432
- var path;
467
+ REST.prototype.collectionPath = function(ids, options) {
468
+ var path, source;
469
+ if (ids == null) {
470
+ ids = [];
471
+ }
433
472
  if (options == null) {
434
473
  options = {};
435
474
  }
475
+ if (Object.isObject(ids)) {
476
+ options = ids;
477
+ ids = [];
478
+ }
436
479
  if (options.url) {
437
480
  return options.url;
438
481
  }
439
- if ((this.__source != null) && (options.parent == null)) {
440
- path = this.__source;
482
+ source = this.__source || this.constructor.__source;
483
+ if (source) {
484
+ path = this.__interpolatePath(source, ids);
441
485
  } else {
442
486
  path = '/';
443
- if (this.__namespace__.length > 0) {
444
- path += this.__namespace__.map(function(s) {
445
- return s.toLowerCase();
446
- }).join('/') + '/';
487
+ if (this.constructor.__namespace__.length > 0) {
488
+ path += this.constructor.__namespace__.map(String.prototype.underscore).join('/') + '/';
447
489
  }
448
- path += this.prototype.__entityName.pluralize();
490
+ path += this.__entityName.pluralize();
449
491
  }
450
- if (options.parent != null) {
451
- path = this.__parentsPath(Object.isArray(options.parent) ? options.parent : [options.parent]) + path;
452
- }
453
- if (options.from != null) {
492
+ if (options.from) {
454
493
  path += "/" + options.from;
455
494
  }
456
495
  return path;
457
496
  };
458
497
 
459
- REST.prototype.collectionPath = function(options) {
460
- if (options == null) {
461
- options = {};
462
- }
463
- return this.constructor.collectionPath(options);
498
+ REST.memberPath = function() {
499
+ var args, _ref1;
500
+ args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
501
+ return (_ref1 = this.prototype).memberPath.apply(_ref1, args);
464
502
  };
465
503
 
466
- REST.memberPath = function(id, options) {
467
- var from, path;
504
+ REST.prototype.memberPath = function(ids, options) {
505
+ var from, id, path;
506
+ if (ids == null) {
507
+ ids = [];
508
+ }
468
509
  if (options == null) {
469
510
  options = {};
470
511
  }
512
+ if (Object.isObject(ids)) {
513
+ options = ids;
514
+ ids = [];
515
+ }
471
516
  if (options.url) {
472
517
  return options.url;
473
518
  }
519
+ if (!Object.isArray(ids)) {
520
+ ids = [ids];
521
+ }
522
+ id = this.id() || ids.pop();
474
523
  from = options.from;
475
- path = this.collectionPath(Object.merge(options, {
524
+ ids.push(this.id());
525
+ path = this.collectionPath(ids, Object.merge(options, {
476
526
  from: void 0
477
527
  })) + ("/" + id);
478
528
  if (from != null) {
@@ -481,79 +531,56 @@
481
531
  return path;
482
532
  };
483
533
 
484
- REST.prototype.memberPath = function(options) {
485
- if (options == null) {
486
- options = {};
487
- }
488
- return this.constructor.memberPath(this.id(), options);
489
- };
490
-
491
534
  REST.get = function(options, callback) {
492
- if (Object.isFunction(options)) {
493
- callback = options;
494
- options = {};
495
- }
535
+ var _ref1;
536
+ _ref1 = this.prototype.__extractOptionsAndCallback(options, callback), options = _ref1[0], callback = _ref1[1];
496
537
  return this.__query(this.collectionPath(options), 'GET', options.params, callback);
497
538
  };
498
539
 
499
540
  REST.post = function(options, callback) {
500
- if (Object.isFunction(options)) {
501
- callback = options;
502
- options = {};
503
- }
541
+ var _ref1;
542
+ _ref1 = this.prototype.__extractOptionsAndCallback(options, callback), options = _ref1[0], callback = _ref1[1];
504
543
  return this.__query(this.collectionPath(options), 'POST', options.params, callback);
505
544
  };
506
545
 
507
546
  REST.put = function(options, callback) {
508
- if (Object.isFunction(options)) {
509
- callback = options;
510
- options = {};
511
- }
547
+ var _ref1;
548
+ _ref1 = this.prototype.__extractOptionsAndCallback(options, callback), options = _ref1[0], callback = _ref1[1];
512
549
  return this.__query(this.collectionPath(options), 'PUT', options.params, callback);
513
550
  };
514
551
 
515
552
  REST["delete"] = function(options, callback) {
516
- if (Object.isFunction(options)) {
517
- callback = options;
518
- options = {};
519
- }
553
+ var _ref1;
554
+ _ref1 = this.prototype.__extractOptionsAndCallback(options, callback), options = _ref1[0], callback = _ref1[1];
520
555
  return this.__query(this.collectionPath(options), 'DELETE', options.params, callback);
521
556
  };
522
557
 
523
558
  REST.prototype.get = function(options, callback) {
524
- if (Object.isFunction(options)) {
525
- callback = options;
526
- options = {};
527
- }
559
+ var _ref1;
560
+ _ref1 = this.__extractOptionsAndCallback(options, callback), options = _ref1[0], callback = _ref1[1];
528
561
  return this.constructor.__query(this.memberPath(options), 'GET', options.params, callback);
529
562
  };
530
563
 
531
564
  REST.prototype.post = function(options, callback) {
532
- if (Object.isFunction(options)) {
533
- callback = options;
534
- options = {};
535
- }
565
+ var _ref1;
566
+ _ref1 = this.__extractOptionsAndCallback(options, callback), options = _ref1[0], callback = _ref1[1];
536
567
  return this.constructor.__query(this.memberPath(options), 'POST', options.params, callback);
537
568
  };
538
569
 
539
570
  REST.prototype.put = function(options, callback) {
540
- if (Object.isFunction(options)) {
541
- callback = options;
542
- options = {};
543
- }
571
+ var _ref1;
572
+ _ref1 = this.__extractOptionsAndCallback(options, callback), options = _ref1[0], callback = _ref1[1];
544
573
  return this.constructor.__query(this.memberPath(options), 'PUT', options.params, callback);
545
574
  };
546
575
 
547
576
  REST.prototype["delete"] = function(options, callback) {
548
- if (Object.isFunction(options)) {
549
- callback = options;
550
- options = {};
551
- }
577
+ var _ref1;
578
+ _ref1 = this.__extractOptionsAndCallback(options, callback), options = _ref1[0], callback = _ref1[1];
552
579
  return this.constructor.__query(this.memberPath(options), 'DELETE', options.params, callback);
553
580
  };
554
581
 
555
582
  REST.find = function(where, options, callback) {
556
- var result,
583
+ var id, path, result, _ref1,
557
584
  _this = this;
558
585
  if (options == null) {
559
586
  options = {};
@@ -561,23 +588,22 @@
561
588
  if (callback == null) {
562
589
  callback = false;
563
590
  }
564
- if (Object.isFunction(options)) {
565
- callback = options;
566
- options = {};
567
- }
568
- if (where === 'all') {
591
+ _ref1 = this.prototype.__extractOptionsAndCallback(options, callback), options = _ref1[0], callback = _ref1[1];
592
+ id = Object.isArray(where) ? where.last() : where;
593
+ if (id === 'all') {
569
594
  result = new (this.prototype.__collection())(this, options);
570
- this.__query(this.collectionPath(options), 'GET', options.params, function(data) {
571
- result.load(data);
572
- return typeof callback === "function" ? callback(result, data) : void 0;
573
- });
595
+ path = this.collectionPath(where, options);
574
596
  } else {
575
- result = this.build(where);
576
- this.__query(this.memberPath(where, options), 'GET', options.params, function(data) {
577
- result.load(data);
578
- return typeof callback === "function" ? callback(result, data) : void 0;
579
- });
597
+ result = this.build(id);
598
+ path = this.memberPath(where, options);
580
599
  }
600
+ if (Object.isArray(where) && where.length > 1) {
601
+ result.__source = this.collectionPath(where);
602
+ }
603
+ this.__query(path, 'GET', options.params, function(data) {
604
+ result.load(data);
605
+ return typeof callback === "function" ? callback(result, data) : void 0;
606
+ });
581
607
  return result;
582
608
  };
583
609
 
@@ -598,23 +624,29 @@
598
624
  };
599
625
 
600
626
  REST.prototype.reload = function(options, callback) {
601
- var _this = this;
627
+ var _ref1,
628
+ _this = this;
602
629
  if (options == null) {
603
630
  options = {};
604
631
  }
605
632
  if (callback == null) {
606
633
  callback = false;
607
634
  }
608
- if (Object.isFunction(options)) {
609
- callback = options;
610
- options = {};
611
- }
635
+ _ref1 = this.__extractOptionsAndCallback(options, callback), options = _ref1[0], callback = _ref1[1];
612
636
  return this.constructor.__query(this.memberPath(options), 'GET', options.params, function(data) {
613
637
  _this.load(data);
614
638
  return typeof callback === "function" ? callback(_this) : void 0;
615
639
  });
616
640
  };
617
641
 
642
+ REST.prototype.__extractOptionsAndCallback = function(options, callback) {
643
+ if (Object.isFunction(options)) {
644
+ callback = options;
645
+ options = {};
646
+ }
647
+ return [options, callback];
648
+ };
649
+
618
650
  return REST;
619
651
 
620
652
  })(Joosy.Resources.Base);
@@ -623,7 +655,8 @@
623
655
  (function() {
624
656
  var _ref,
625
657
  __hasProp = {}.hasOwnProperty,
626
- __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; };
658
+ __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; },
659
+ __slice = [].slice;
627
660
 
628
661
  Joosy.Resources.RESTCollection = (function(_super) {
629
662
  __extends(RESTCollection, _super);
@@ -649,12 +682,23 @@
649
682
  callback = options;
650
683
  options = {};
651
684
  }
652
- return this.model.__query(this.model.collectionPath(options), 'GET', options.params, function(data) {
685
+ return this.model.__query(this.model.collectionPath(options, this.__source), 'GET', options.params, function(data) {
653
686
  _this.load(data);
654
687
  return typeof callback === "function" ? callback(data) : void 0;
655
688
  });
656
689
  };
657
690
 
691
+ RESTCollection.prototype.load = function() {
692
+ var args, res,
693
+ _this = this;
694
+ args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
695
+ res = RESTCollection.__super__.load.apply(this, args);
696
+ this.data.each(function(x) {
697
+ return x.__source = _this.__source;
698
+ });
699
+ return res;
700
+ };
701
+
658
702
  return RESTCollection;
659
703
 
660
704
  })(Joosy.Resources.Collection);
data/build/joosy.js CHANGED
@@ -1809,6 +1809,7 @@
1809
1809
  (function() {
1810
1810
  Joosy.helpers('Routes', function() {
1811
1811
  return this.linkTo = function(name, url, tagOptions) {
1812
+ var block, _ref;
1812
1813
  if (name == null) {
1813
1814
  name = '';
1814
1815
  }
@@ -1819,9 +1820,9 @@
1819
1820
  tagOptions = {};
1820
1821
  }
1821
1822
  if (Object.isFunction(tagOptions)) {
1822
- url = name;
1823
- tagOptions = url;
1824
- name = tagOptions();
1823
+ block = tagOptions;
1824
+ _ref = [name, url], url = _ref[0], tagOptions = _ref[1];
1825
+ name = block();
1825
1826
  }
1826
1827
  return Joosy.Helpers.Application.contentTag('a', name, Joosy.Module.merge(tagOptions, {
1827
1828
  'data-joosy': true,
@@ -3,7 +3,6 @@
3
3
  #= require joosy
4
4
  #
5
5
  #= require_tree ./
6
- #= require_self
7
6
 
8
7
  $ ->
9
8
  Joosy.Application.initialize 'body',
data/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "keywords": [
5
5
  "joosy"
6
6
  ],
7
- "version": "1.2.0-alpha.58",
7
+ "version": "1.2.0-alpha.59",
8
8
  "author": "Boris Staal <boris@staal.io>",
9
9
  "homepage": "http://joosy.ws/",
10
10
  "repository": {
@@ -18,7 +18,7 @@
18
18
  "node": ">=0.4.0"
19
19
  },
20
20
  "dependencies": {
21
- "bower": "~1.1.0",
21
+ "grill": "~1.0.0-alpha.3",
22
22
  "sugar": "~1.3.8",
23
23
  "coffee-script": "~1.6.3",
24
24
  "command-router": "0.0.5",
@@ -28,10 +28,6 @@
28
28
  "colors": "~0.6.0-1",
29
29
  "grunt": "~0.4.1",
30
30
  "mincer": ">= 0.5.5",
31
- "connect": "~2.7.11",
32
- "haml-coffee": "~1.11.1",
33
- "proxy-middleware": "~0.4.0",
34
- "gzippo": "~0.2.0",
35
31
  "stylus": "~0.32.1",
36
32
  "nib": "~0.9.1"
37
33
  },
@@ -42,6 +38,7 @@
42
38
  "grunt-contrib-connect": "~0.3.0",
43
39
  "grunt-coffeelint": "0.0.6",
44
40
  "grunt-release": "~0.3.5",
45
- "semver": "~2.1.0"
41
+ "semver": "~2.1.0",
42
+ "bower": "~1.1.2"
46
43
  }
47
44
  }
@@ -27,8 +27,6 @@ class Joosy.Resources.Base extends Joosy.Module
27
27
  #
28
28
  __primaryKey: 'id'
29
29
 
30
- __source: false
31
-
32
30
  #
33
31
  # Clears the identity map cache. Recomended to be called during layout switch to
34
32
  # ensure correct garbage collection.
@@ -55,7 +53,8 @@ class Joosy.Resources.Base extends Joosy.Module
55
53
  #
56
54
  # @param [String] primary Name of the field
57
55
  #
58
- @primaryKey: (primaryKey) -> @::__primaryKey = primaryKey
56
+ @primaryKey: (primaryKey) ->
57
+ @::__primaryKey = primaryKey
59
58
 
60
59
  #
61
60
  # Sets the entity text name:
@@ -63,7 +62,8 @@ class Joosy.Resources.Base extends Joosy.Module
63
62
  #
64
63
  # @param [String] name Singular name of resource
65
64
  #
66
- @entity: (name) -> @::__entityName = name
65
+ @entity: (name) ->
66
+ @::__entityName = name
67
67
 
68
68
  #
69
69
  # Sets the collection to use
@@ -128,16 +128,7 @@ class Joosy.Resources.Base extends Joosy.Module
128
128
  Joosy.Resources.Base.identity ||= {}
129
129
  Joosy.Resources.Base.identity[klass] ||= {}
130
130
 
131
- shim = ->
132
- shim.__call.apply shim, arguments
133
-
134
- if shim.__proto__
135
- shim.__proto__ = @prototype
136
- else
137
- for key, value of @prototype
138
- shim[key] = value
139
-
140
- shim.constructor = @
131
+ shim = @__makeShim(@::)
141
132
 
142
133
  if Object.isNumber(data) || Object.isString(data)
143
134
  id = data
@@ -158,6 +149,25 @@ class Joosy.Resources.Base extends Joosy.Module
158
149
 
159
150
  shim
160
151
 
152
+ #
153
+ # Makes base shim-function for making instances through build or making instance clones
154
+ #
155
+ # @param [Object] proto Any function or object whose properties will be inherited by a new function
156
+ #
157
+ @__makeShim: (proto) ->
158
+ shim = ->
159
+ shim.__call.apply shim, arguments
160
+
161
+ if shim.__proto__
162
+ shim.__proto__ = proto
163
+ else
164
+ for key, value of proto
165
+ shim[key] = value
166
+
167
+ shim.constructor = @
168
+
169
+ shim
170
+
161
171
  #
162
172
  # Should NOT be called directly, use {::build} instead
163
173
  #
@@ -168,7 +178,7 @@ class Joosy.Resources.Base extends Joosy.Module
168
178
  @__fillData data, false
169
179
 
170
180
  id: ->
171
- @data[@__primaryKey]
181
+ @data?[@__primaryKey]
172
182
 
173
183
  knownAttributes: ->
174
184
  Object.keys @data