slender_data 0.4.0 → 0.4.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad1f6ff2a238e3b68f7204ab22075983ec2bb710
|
4
|
+
data.tar.gz: d51c1b59474a55476518221e59aaf0532be40d72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da7503aaf3a208e102a3993acfd4cc98043d24a3eb3faa56dfe6ee2a7c0d2636e75018b27b4bb91e354b71036ea9372bccf75446340cb3113314eec895711ff5
|
7
|
+
data.tar.gz: 9748a79bf0da516420de67e49d1410424a1b0774b5cd3ece06d553ef34bfa9dcd91bff74166f8d94cec11648db984b90ef40e7bad9f2a022bc4d495d120291f1
|
@@ -48,8 +48,8 @@ class slender_data.PersistenceManager
|
|
48
48
|
|
49
49
|
|
50
50
|
# Adds the given data objects to the server cache.
|
51
|
-
add_all: (
|
52
|
-
@
|
51
|
+
add_all: (entries) ->
|
52
|
+
@add(entry) for entry in entries
|
53
53
|
|
54
54
|
|
55
55
|
# Returns an array containing only the changed objects.
|
@@ -128,8 +128,8 @@ class slender_data.PersistenceManager
|
|
128
128
|
# Fetches the entry with the given key from the server.
|
129
129
|
# Adds it to the clientside cache.
|
130
130
|
fetch: (key, success_callback) ->
|
131
|
-
@loader.get "#{@base_url}/#{key}.json", (
|
132
|
-
client_entry = @add
|
131
|
+
@loader.get "#{@base_url}/#{key}.json", (server_response) =>
|
132
|
+
client_entry = @add server_response[@model_name]
|
133
133
|
success_callback client_entry
|
134
134
|
|
135
135
|
|
@@ -142,7 +142,7 @@ class slender_data.PersistenceManager
|
|
142
142
|
cache: no
|
143
143
|
data: data
|
144
144
|
success: (data) =>
|
145
|
-
@
|
145
|
+
@add_all data
|
146
146
|
success_callback(data) if success_callback
|
147
147
|
error: (xhr) ->
|
148
148
|
error_callback(xhr.responseText) if error_callback
|
@@ -194,10 +194,12 @@ class slender_data.PersistenceManager
|
|
194
194
|
load_many: (ids, success_callback) ->
|
195
195
|
[cached_entries, missing_ids] = @get_many ids
|
196
196
|
if missing_ids.length == 0
|
197
|
-
return
|
198
|
-
|
199
|
-
|
200
|
-
|
197
|
+
# All requested entries found in cache --> return them immediately.
|
198
|
+
success_callback(cached_entries)
|
199
|
+
else
|
200
|
+
# Entries missing --> load them from the server.
|
201
|
+
@fetch_all missing_ids, (server_snippets) ->
|
202
|
+
success_callback $.merge(cached_entries, server_snippets)
|
201
203
|
|
202
204
|
|
203
205
|
# Saves the given object.
|
@@ -235,11 +237,8 @@ class slender_data.PersistenceManager
|
|
235
237
|
type: 'PUT'
|
236
238
|
data: data
|
237
239
|
success: (server_response) =>
|
238
|
-
|
239
|
-
@
|
240
|
-
client_obj = slender_data.clone_hash server_obj
|
241
|
-
@client_data.add client_obj
|
242
|
-
success_callback client_obj if success_callback
|
240
|
+
@client_entry = @add server_response[@model_name]
|
241
|
+
success_callback @client_entry if success_callback
|
243
242
|
error: (xhr) ->
|
244
243
|
error_callback(xhr.responseText) if error_callback
|
245
244
|
|
data/lib/slender_data/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slender_data
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Goslar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|