slender_data 0.2.0 → 0.3.0

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: d219af00b0955ed12a4724a45274fbbdcfad22d2
4
- data.tar.gz: 1e55017fea414a68625b7076f61bba42f46991ac
3
+ metadata.gz: f507b704a233dcf4a01acb86b22cd5400e250e9c
4
+ data.tar.gz: ce8f7bd91529b3f8b24c7f8d490f4d1d52c0d7aa
5
5
  SHA512:
6
- metadata.gz: 003380a4bc570c13031e817ca35673904b6270dc1d1d4445e8e066258055cc43c0e3835866c557cd792232821f3cb64276c5f041bde7079c78774307a99ee103
7
- data.tar.gz: 91d95a4d10aae259c87f1f7461808dc9c03e5fc99816f6be1a01d2a40b134f209df11715b63a9f04e5a77a2aada10553277657a9e3775c1369a8bcf9806255ef
6
+ metadata.gz: b6a9021c2c2e152e0c44a5470b908df3babbff4ea08d08c7c5e6cfe848867a6331de41ba384f8577b79e208520340d43cff974bc4ff7e098eddf8c66e2a03099
7
+ data.tar.gz: 6a6d8df07e91f0dac3c8a072ac6fc5bf78de8649330fd58b6df95301354ff0a4d9c8b0efc8676c0589fefaef2f057935d5a4bf8d25a8533d2a49eb1da2f42a39
@@ -14,6 +14,7 @@ class slender_data.IndexedCache
14
14
 
15
15
  add_all: (entries) ->
16
16
  @add(entry) for entry in entries
17
+ return # Prevents inefficient JS code.
17
18
 
18
19
 
19
20
  remove: (entry_id) ->
@@ -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: (params, success_callback, error_callback) ->
138
+ fetch_all: (ids, success_callback, error_callback) ->
139
139
  jQuery.ajax
140
140
  url: @collection_url()
141
141
  cache: no
142
- data: params
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 ndefined if no object with this key exists in the cache.
152
- get_cached_entry: (key) ->
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
- get_cached_entries: (ids) ->
171
+ get_many: (ids) ->
172
172
  entries = []
173
173
  missing_ids = []
174
174
  for id in ids
175
- if (entry = @get_cached_entry(id))
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 = @get_cached_entry key
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] = @get_cached_entries(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
 
@@ -1,3 +1,3 @@
1
1
  module SlenderData
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
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.2.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-01 00:00:00.000000000 Z
11
+ date: 2013-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails