eyeballs 0.5.6.1 → 0.5.7

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/CHANGELOG CHANGED
@@ -1,6 +1,7 @@
1
1
  Fri Aug 6
2
2
  - - - - -
3
3
  - Add support for passing params from the URL to the controller
4
+ - Add proper callbacks and reading a response to .find
4
5
 
5
6
  Sun Aug 1
6
7
  - - - - -
data/Rakefile CHANGED
@@ -27,7 +27,7 @@ begin
27
27
  require 'jeweler'
28
28
  Jeweler::Tasks.new do |s|
29
29
  s.name = "eyeballs"
30
- s.version = "0.5.6.1"
30
+ s.version = "0.5.7"
31
31
  s.author = "Paul Campbell"
32
32
  s.email = "paul@rslw.com"
33
33
  s.homepage = "http://www.github.com/paulca/eyeballs.js"
data/app.rb CHANGED
@@ -15,6 +15,10 @@ post '/alternate_reviews' do
15
15
  '{"id": "2"}'
16
16
  end
17
17
 
18
+ get '/string_back' do
19
+ 'found a string'
20
+ end
21
+
18
22
  post '/string_back' do
19
23
  'some string'
20
24
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{eyeballs}
8
- s.version = "0.5.6.1"
8
+ s.version = "0.5.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Paul Campbell"]
@@ -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' && options.prefix)
103
+ if(typeof options === 'object')
104
104
  {
105
- url = options.prefix + url;
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
- var retrieved_object = JSON.parse(response);
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
  }
@@ -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
  }
@@ -114,7 +114,7 @@
114
114
  });
115
115
  });
116
116
 
117
- asyncTest('consistent ID on string back', function(){
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: 125
4
+ hash: 5
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 6
10
- - 1
11
- version: 0.5.6.1
9
+ - 7
10
+ version: 0.5.7
12
11
  platform: ruby
13
12
  authors:
14
13
  - Paul Campbell