redis_assist 0.5.0 → 0.6.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 +4 -4
- data/lib/redis_assist/base.rb +33 -5
- data/lib/redis_assist/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d8b5ade8e21adfb3171216c7618e166dc7e8e55
|
4
|
+
data.tar.gz: 43248a5dc1e57fc020498dcabe815b9e2d8af2a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 729ae7bdc99c90e98c2c2721c1cc16c584d18511453653af167615465bddcaf3f4d20099d5c0a9ea950ab0cb2eef7d30d37e43a3a6a6daaae5c30a7b31d585f4
|
7
|
+
data.tar.gz: ea1cec9f67c175c0cbc8a5eeeb2f0fe52f194c547418f8e5dd53c295bade7f3d80f06b4bcfd6b824494af9fd372a7c668a246dbfac97d22b77c6ea1f882713c0
|
data/lib/redis_assist/base.rb
CHANGED
@@ -108,7 +108,7 @@ module RedisAssist
|
|
108
108
|
|
109
109
|
# TODO: needs a refactor. Should this be an interface for skipping validations?
|
110
110
|
# Should we optimize and skip the find? Support an array of ids?
|
111
|
-
def update(id, params={})
|
111
|
+
def update(id, params={}, opts={})
|
112
112
|
record = find(id)
|
113
113
|
return false unless record
|
114
114
|
|
@@ -287,9 +287,6 @@ module RedisAssist
|
|
287
287
|
self.lists = {}
|
288
288
|
self.hashes = {}
|
289
289
|
|
290
|
-
if attrs[:id]
|
291
|
-
end
|
292
|
-
|
293
290
|
if attrs[:id]
|
294
291
|
self.id = attrs[:id]
|
295
292
|
load_attributes(attrs[:raw_attributes])
|
@@ -338,7 +335,8 @@ module RedisAssist
|
|
338
335
|
if !hashes[name] && opts[:default]
|
339
336
|
opts[:default]
|
340
337
|
else
|
341
|
-
self.send("#{name}=", hashes[name].value)
|
338
|
+
self.send("#{name}=", hashes[name].value) if hashes[name].is_a?(Redis::Future)
|
339
|
+
hashes[name]
|
342
340
|
end
|
343
341
|
end
|
344
342
|
|
@@ -363,6 +361,36 @@ module RedisAssist
|
|
363
361
|
def saved?
|
364
362
|
!!(new_record?.eql?(false) && id)
|
365
363
|
end
|
364
|
+
|
365
|
+
# Update fields without hitting the callbacks
|
366
|
+
def update_columns(attrs)
|
367
|
+
redis.multi do
|
368
|
+
attrs.each do |attr, value|
|
369
|
+
if self.class.fields.has_key?(attr)
|
370
|
+
write_attribute(attr, value)
|
371
|
+
redis.hset(key_for(:attributes), attr, value) unless new_record?
|
372
|
+
end
|
373
|
+
|
374
|
+
if self.class.lists.has_key?(attr)
|
375
|
+
write_list(attr, value)
|
376
|
+
|
377
|
+
unless new_record?
|
378
|
+
redis.del(key_for(attr))
|
379
|
+
redis.rpush(key_for(attr), value) unless value.empty?
|
380
|
+
end
|
381
|
+
end
|
382
|
+
|
383
|
+
if self.class.hashes.has_key?(attr)
|
384
|
+
write_hash(attr, value)
|
385
|
+
|
386
|
+
unless new_record?
|
387
|
+
hash_as_args = hash_to_redis(value)
|
388
|
+
redis.hmset(key_for(attr), *hash_as_args)
|
389
|
+
end
|
390
|
+
end
|
391
|
+
end
|
392
|
+
end
|
393
|
+
end
|
366
394
|
|
367
395
|
def save
|
368
396
|
return false unless valid?
|
data/lib/redis_assist/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis_assist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Love
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|