redis_assist 0.5.0 → 0.6.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: feb40ab214f985e7c59f88cebb16ca40a75eb686
4
- data.tar.gz: ec8328f304d326609fbc738db79fde27102fb7a5
3
+ metadata.gz: 7d8b5ade8e21adfb3171216c7618e166dc7e8e55
4
+ data.tar.gz: 43248a5dc1e57fc020498dcabe815b9e2d8af2a4
5
5
  SHA512:
6
- metadata.gz: 515e9d3708aa53e8d819271d248c857679c906c4ac28b95aa997a1982b887c5e15aada064eeafcb788461e2b71f26e64d355634adf6c274a39d53e22d507b1ff
7
- data.tar.gz: b0d545b698f646dab29ff5de7e8d633c784bf7cc7a93e8916dec85f15492fe0cac75d80b41b683b196b6ceb99c728e2b5c15722e4235d0157d8e4d50735eeaf6
6
+ metadata.gz: 729ae7bdc99c90e98c2c2721c1cc16c584d18511453653af167615465bddcaf3f4d20099d5c0a9ea950ab0cb2eef7d30d37e43a3a6a6daaae5c30a7b31d585f4
7
+ data.tar.gz: ea1cec9f67c175c0cbc8a5eeeb2f0fe52f194c547418f8e5dd53c295bade7f3d80f06b4bcfd6b824494af9fd372a7c668a246dbfac97d22b77c6ea1f882713c0
@@ -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?
@@ -1,3 +1,3 @@
1
1
  module RedisAssist
2
- VERSION = '0.5.0' unless defined?(::RedisAssist::VERSION)
2
+ VERSION = '0.6.0' unless defined?(::RedisAssist::VERSION)
3
3
  end
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.5.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-24 00:00:00.000000000 Z
11
+ date: 2013-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis