ember-rest-rails 0.0.1 → 0.0.2
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.
- data/README.md +2 -2
- data/lib/ember_rest_rails/version.rb +1 -1
- data/vendor/assets/javascripts/ember-rest.js +38 -9
- metadata +2 -2
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# Ember::Rest::Rails
|
2
2
|
|
3
3
|
Allows you to include
|
4
|
-
[Ember-REST](https://github.com/cerebris/ember-rest) in your Rails 3
|
4
|
+
[Ember-REST](https://github.com/cerebris/ember-rest) in your Rails 3
|
5
5
|
Application.
|
6
6
|
|
7
|
-
Ember-REST version is
|
7
|
+
Ember-REST version is 0.1.1 (works with Ember.js 0.9.6).
|
8
8
|
|
9
9
|
## Installation
|
10
10
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
Ember-REST.js
|
2
|
+
Ember-REST.js 0.1.1
|
3
3
|
|
4
4
|
A simple library for RESTful resources in Ember.js
|
5
5
|
|
@@ -65,7 +65,7 @@ if (Ember.ResourceAdapter === undefined) {
|
|
65
65
|
* `deserializeProperty(prop, value)`
|
66
66
|
* `validate()`
|
67
67
|
*/
|
68
|
-
Ember.Resource = Ember.Object.extend({
|
68
|
+
Ember.Resource = Ember.Object.extend(Ember.ResourceAdapter, Ember.Copyable, {
|
69
69
|
resourceIdField: 'id',
|
70
70
|
resourceUrl: Ember.required(),
|
71
71
|
|
@@ -87,6 +87,20 @@ Ember.Resource = Ember.Object.extend({
|
|
87
87
|
}
|
88
88
|
},
|
89
89
|
|
90
|
+
/**
|
91
|
+
Create a copy of this resource
|
92
|
+
|
93
|
+
Needed to implement Ember.Copyable
|
94
|
+
|
95
|
+
REQUIRED: `resourceProperties`
|
96
|
+
*/
|
97
|
+
copy: function(deep) {
|
98
|
+
var c = this.constructor.create();
|
99
|
+
c.duplicateProperties(this);
|
100
|
+
c.set(this.resourceIdField, this.get(this.resourceIdField));
|
101
|
+
return c;
|
102
|
+
},
|
103
|
+
|
90
104
|
/**
|
91
105
|
Generate this resource's JSON representation
|
92
106
|
|
@@ -224,7 +238,7 @@ Ember.Resource = Ember.Object.extend({
|
|
224
238
|
_resourceId: function() {
|
225
239
|
return this.get(this.resourceIdField);
|
226
240
|
}
|
227
|
-
}
|
241
|
+
});
|
228
242
|
|
229
243
|
/**
|
230
244
|
A controller for RESTful resources
|
@@ -236,7 +250,7 @@ Ember.Resource = Ember.Object.extend({
|
|
236
250
|
* `resourceUrl` -- (optional) the base url of the resource (e.g. '/contacts/active');
|
237
251
|
will default to the `resourceUrl` for `resourceType`
|
238
252
|
*/
|
239
|
-
Ember.ResourceController = Ember.ArrayController.extend({
|
253
|
+
Ember.ResourceController = Ember.ArrayController.extend(Ember.ResourceAdapter, {
|
240
254
|
resourceType: Ember.required(),
|
241
255
|
|
242
256
|
/**
|
@@ -292,9 +306,24 @@ Ember.ResourceController = Ember.ArrayController.extend({
|
|
292
306
|
the `resourceUrl` specified for `resourceType`.
|
293
307
|
*/
|
294
308
|
_resourceUrl: function() {
|
295
|
-
if (this.resourceUrl === undefined)
|
296
|
-
|
297
|
-
|
298
|
-
|
309
|
+
if (this.resourceUrl === undefined) {
|
310
|
+
// If `resourceUrl` is not defined for this controller, there are a couple
|
311
|
+
// ways to retrieve it from the resource. If a resource has been instantiated,
|
312
|
+
// then it can be retrieved from the resource's prototype. Otherwise, we need
|
313
|
+
// to loop through the mixins for the prototype to get the resourceUrl.
|
314
|
+
var rt = this.get('resourceType');
|
315
|
+
if (rt.prototype.resourceUrl === undefined) {
|
316
|
+
for (var i = rt.PrototypeMixin.mixins.length - 1; i >= 0; i--) {
|
317
|
+
var m = rt.PrototypeMixin.mixins[i];
|
318
|
+
if (m.properties !== undefined && m.properties.resourceUrl !== undefined) {
|
319
|
+
return m.properties.resourceUrl;
|
320
|
+
}
|
321
|
+
}
|
322
|
+
}
|
323
|
+
else {
|
324
|
+
return rt.prototype.resourceUrl;
|
325
|
+
}
|
326
|
+
}
|
327
|
+
return this.resourceUrl;
|
299
328
|
}
|
300
|
-
}
|
329
|
+
});
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ember-rest-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|