eyeballs 0.5.6.1 → 0.5.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +1 -0
- data/Rakefile +1 -1
- data/app.rb +4 -0
- data/eyeballs.gemspec +1 -1
- data/src/drivers/jquery/adapters/o_O.rest.js +15 -4
- data/src/modules/o_O.model.js +4 -4
- data/test/unit/test_rest.html +16 -1
- metadata +3 -4
data/CHANGELOG
CHANGED
data/Rakefile
CHANGED
data/app.rb
CHANGED
data/eyeballs.gemspec
CHANGED
@@ -100,16 +100,27 @@ o_O.rest = {
|
|
100
100
|
find: function(model, id, callback, options)
|
101
101
|
{
|
102
102
|
var url = '/' + model.table_name + '/' + id;
|
103
|
-
if(typeof options === 'object'
|
103
|
+
if(typeof options === 'object')
|
104
104
|
{
|
105
|
-
|
105
|
+
if(options['url']){
|
106
|
+
url = options['url'];
|
107
|
+
}
|
108
|
+
else if(options['prefix'])
|
109
|
+
{
|
110
|
+
url = options.prefix + url;
|
111
|
+
}
|
106
112
|
}
|
107
113
|
$.get(url, function(response){
|
108
|
-
|
114
|
+
try{
|
115
|
+
var retrieved_object = JSON.parse(response);
|
116
|
+
}
|
117
|
+
catch(e){
|
118
|
+
var retrieved_object = model.initialize({id: id});
|
119
|
+
}
|
109
120
|
if(typeof callback === 'function')
|
110
121
|
{
|
111
122
|
retrieved_object.new_record = false;
|
112
|
-
callback(retrieved_object);
|
123
|
+
callback(retrieved_object, response);
|
113
124
|
}
|
114
125
|
})
|
115
126
|
}
|
data/src/modules/o_O.model.js
CHANGED
@@ -179,9 +179,9 @@ o_O.model = {
|
|
179
179
|
find: function(id, callback){
|
180
180
|
if(this.adapter)
|
181
181
|
{
|
182
|
-
run_callback(callback, 'loading', this)
|
182
|
+
run_callback(callback, 'loading', this.initialize({id: id}))
|
183
183
|
var model = this;
|
184
|
-
return this.adapter.find(this, id, function(returned_object){
|
184
|
+
return this.adapter.find(this, id, function(returned_object, response){
|
185
185
|
found_object = model.initialize(returned_object);
|
186
186
|
if(!found_object['new_record'])
|
187
187
|
{
|
@@ -189,11 +189,11 @@ o_O.model = {
|
|
189
189
|
}
|
190
190
|
if(found_object.id)
|
191
191
|
{
|
192
|
-
run_callback(callback, 'success', found_object);
|
192
|
+
run_callback(callback, 'success', found_object, response);
|
193
193
|
}
|
194
194
|
else
|
195
195
|
{
|
196
|
-
run_callback(callback, 'failure', found_object);
|
196
|
+
run_callback(callback, 'failure', found_object, response);
|
197
197
|
}
|
198
198
|
}, callback);
|
199
199
|
}
|
data/test/unit/test_rest.html
CHANGED
@@ -114,7 +114,7 @@
|
|
114
114
|
});
|
115
115
|
});
|
116
116
|
|
117
|
-
asyncTest('consistent ID
|
117
|
+
asyncTest('consistent ID save with string back', function(){
|
118
118
|
var string_back_id;
|
119
119
|
Review.create({},{
|
120
120
|
url: "/string_back",
|
@@ -128,6 +128,21 @@
|
|
128
128
|
});
|
129
129
|
});
|
130
130
|
|
131
|
+
asyncTest('consistent ID find with string back', function(){
|
132
|
+
var string_back_id;
|
133
|
+
Review.find({},{
|
134
|
+
url: "/string_back",
|
135
|
+
loading: function(found_review){
|
136
|
+
string_back_id = found_review.id;
|
137
|
+
},
|
138
|
+
success: function(found_review, response){
|
139
|
+
equals(response, 'found a string', 'should give me a string back!');
|
140
|
+
equals(found_review.id, string_back_id, 'ids should be the same');
|
141
|
+
start();
|
142
|
+
}
|
143
|
+
});
|
144
|
+
});
|
145
|
+
|
131
146
|
asyncTest('pulling something in', 2, function(){
|
132
147
|
var review = Review.initialize({title: 'More Magic!'});
|
133
148
|
review.save(function(){
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eyeballs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
|
11
|
-
version: 0.5.6.1
|
9
|
+
- 7
|
10
|
+
version: 0.5.7
|
12
11
|
platform: ruby
|
13
12
|
authors:
|
14
13
|
- Paul Campbell
|