slender_data 0.2.0 → 0.3.0
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f507b704a233dcf4a01acb86b22cd5400e250e9c
|
4
|
+
data.tar.gz: ce8f7bd91529b3f8b24c7f8d490f4d1d52c0d7aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6a9021c2c2e152e0c44a5470b908df3babbff4ea08d08c7c5e6cfe848867a6331de41ba384f8577b79e208520340d43cff974bc4ff7e098eddf8c66e2a03099
|
7
|
+
data.tar.gz: 6a6d8df07e91f0dac3c8a072ac6fc5bf78de8649330fd58b6df95301354ff0a4d9c8b0efc8676c0589fefaef2f057935d5a4bf8d25a8533d2a49eb1da2f42a39
|
@@ -135,11 +135,11 @@ class slender_data.PersistenceManager
|
|
135
135
|
|
136
136
|
# Loads all objects from the server.
|
137
137
|
# Provides the given params as parameters to the GET request.
|
138
|
-
fetch_all: (
|
138
|
+
fetch_all: (ids, success_callback, error_callback) ->
|
139
139
|
jQuery.ajax
|
140
140
|
url: @collection_url()
|
141
141
|
cache: no
|
142
|
-
data:
|
142
|
+
data: ids
|
143
143
|
success: (data) =>
|
144
144
|
@server_data.add_all data
|
145
145
|
success_callback(data) if success_callback
|
@@ -148,8 +148,8 @@ class slender_data.PersistenceManager
|
|
148
148
|
|
149
149
|
|
150
150
|
# Returns the cached object with the given key, if one exists in the cache.
|
151
|
-
# Returns
|
152
|
-
|
151
|
+
# Returns undefined if no object with this key exists in the cache.
|
152
|
+
get: (key) =>
|
153
153
|
|
154
154
|
# Try to use client_data cache.
|
155
155
|
client_obj = @client_data.get key
|
@@ -168,11 +168,11 @@ class slender_data.PersistenceManager
|
|
168
168
|
|
169
169
|
# Returns all entries that are in the cache,
|
170
170
|
# and the ids of all entries that are not cached.
|
171
|
-
|
171
|
+
get_many: (ids) ->
|
172
172
|
entries = []
|
173
173
|
missing_ids = []
|
174
174
|
for id in ids
|
175
|
-
if (entry = @
|
175
|
+
if (entry = @get id)
|
176
176
|
entries.push entry
|
177
177
|
else
|
178
178
|
missing_ids.push id
|
@@ -183,7 +183,7 @@ class slender_data.PersistenceManager
|
|
183
183
|
load: (key, success_callback) ->
|
184
184
|
|
185
185
|
# Try to load from cache.
|
186
|
-
return success_callback(entry) if entry = @
|
186
|
+
return success_callback(entry) if entry = @get key
|
187
187
|
|
188
188
|
# No data on client --> load from server.
|
189
189
|
@fetch key, success_callback
|
@@ -191,7 +191,7 @@ class slender_data.PersistenceManager
|
|
191
191
|
|
192
192
|
# Loads all entries with the given ids.
|
193
193
|
load_many: (ids, success_callback) ->
|
194
|
-
[cached_entries, missing_ids] = @
|
194
|
+
[cached_entries, missing_ids] = @get_many ids
|
195
195
|
if missing_ids.length == 0
|
196
196
|
return success_callback(cached_entries)
|
197
197
|
|
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
|
+
version: 0.3.0
|
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-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|