vault-rails 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
data/lib/vault-rails/version.rb
CHANGED
@@ -179,6 +179,33 @@ class Vault
|
|
179
179
|
# Object not found.
|
180
180
|
return false
|
181
181
|
|
182
|
+
# Forcibly remove an object from the collection.
|
183
|
+
destroy: (id) ->
|
184
|
+
# Don't bother if the vault is locked.
|
185
|
+
if @locked
|
186
|
+
@errors.push 'Cannot delete, vault is locked.'
|
187
|
+
return false
|
188
|
+
|
189
|
+
for object, index in @objects
|
190
|
+
if object[@options.id_attribute] == id
|
191
|
+
# Remove the object from the collection.
|
192
|
+
@objects.splice(index, 1)
|
193
|
+
|
194
|
+
# Reduce the dirty count if this object
|
195
|
+
# was dirty, since we're no longer managing it.
|
196
|
+
switch object.status
|
197
|
+
when "new", "dirty"
|
198
|
+
@dirty_object_count--
|
199
|
+
|
200
|
+
# Store the collection.
|
201
|
+
@store
|
202
|
+
|
203
|
+
# Destroy was successful.
|
204
|
+
return true
|
205
|
+
|
206
|
+
# Object not found.
|
207
|
+
return false
|
208
|
+
|
182
209
|
# Write an object back to the server.
|
183
210
|
save: (id, after_save = ->) ->
|
184
211
|
# Don't bother if the vault is locked, we're offline or there's nothing to sync.
|
@@ -357,6 +384,8 @@ class Vault
|
|
357
384
|
@update(attributes, object.id)
|
358
385
|
object.delete = =>
|
359
386
|
@delete(object.id)
|
387
|
+
object.destroy = =>
|
388
|
+
@destroy(object.id)
|
360
389
|
object.save = (after_save) =>
|
361
390
|
@save(object.id, after_save)
|
362
391
|
|
@@ -481,9 +510,11 @@ class Vault
|
|
481
510
|
if object_clone.status is "new"
|
482
511
|
delete object_clone[@options.id_attribute]
|
483
512
|
|
513
|
+
# Remove vault object methods.
|
484
514
|
delete object_clone.status
|
485
515
|
delete object_clone.update
|
486
516
|
delete object_clone.delete
|
517
|
+
delete object_clone.destroy
|
487
518
|
delete object_clone.save
|
488
519
|
|
489
520
|
# Iterate through all of the sub-collections, and if present
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vault-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-11-
|
12
|
+
date: 2011-11-23 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description: Store and manage collections of objects without a connection.
|
15
15
|
email:
|