active_redis_orm 0.1.3 → 0.1.4

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: 93c66b738cb2ef6d799069c81595d3ab66f25c55
4
- data.tar.gz: 575fb512ebd7a16ad02b5aa1ff42630ce9be7c52
3
+ metadata.gz: 4cf1a60fe40cbc3ca7157cb6908c6313c8b098f3
4
+ data.tar.gz: 3181c522dee6fffe76007f91f315e4b1d0d4607f
5
5
  SHA512:
6
- metadata.gz: a5d004a2dab86ec0d53272b4f8f10e5c8357fc4a89a8c139fbb8aca8398f472c2df29e093d81ac330bb5dad60dfe7494c43af70f1b3dc81cb0c189713007366a
7
- data.tar.gz: ff3af39d4b678b13c49191b3afdc81c5f7c34251513f0f4feeb545c800c066c6e0886758f055c5a86b4beb88927d3714e6d5105358753b7b7d433311cecc54ae
6
+ metadata.gz: 4f342d78a19d49459d42648ad9853b4d706178a971cb0d2c7a4073b3557e4f298ec293fb5c31d5f928f80f0beb1cb145d8be93519132248597aa94f7477ef402
7
+ data.tar.gz: 3f6192eefe2d7848cec11543b8eb392c56e89d61259504427b13340c986e9bd8fa72965551ace8d756d07db0c539cede1a0cf4ff15b2fc895533a0e2e07c0843
@@ -290,6 +290,7 @@ module ActiveRedis
290
290
  changes[:drops].each do |drop|
291
291
  #{field_name}_object.delete(drop)
292
292
  end
293
+ #{field_name}.clean!
293
294
  after_set(:#{field_name})
294
295
  end
295
296
  }
@@ -323,6 +324,7 @@ module ActiveRedis
323
324
  changes[:drops].each do |drop|
324
325
  #{field_name}_object.delete(drop)
325
326
  end
327
+ #{field_name}.clean!
326
328
  after_set(:#{field_name})
327
329
  end
328
330
  }
@@ -357,6 +359,7 @@ module ActiveRedis
357
359
  changes[:drops].each do |drop|
358
360
  self.#{field_name}_object.delete(drop)
359
361
  end
362
+ #{field_name}.clean!
360
363
  after_set(:#{field_name})
361
364
  end
362
365
  }
@@ -387,6 +390,7 @@ module ActiveRedis
387
390
  changes[:drops].each do |drop|
388
391
  #{field_name}_hash_set.delete(drop)
389
392
  end
393
+ #{field_name}.clean!
390
394
  after_set(:#{field_name})
391
395
  end
392
396
  }
@@ -11,6 +11,10 @@ module ActiveRedis
11
11
  @original != self
12
12
  end
13
13
 
14
+ def clean!
15
+ @original = dup
16
+ end
17
+
14
18
  def changes
15
19
  {additions: self - @original, drops: @original - self}
16
20
  end
@@ -21,6 +21,10 @@ module ActiveRedis
21
21
  @original.keys - self.keys
22
22
  end
23
23
 
24
+ def clean!
25
+ @original = dup
26
+ end
27
+
24
28
  def updated_keys
25
29
  self.keys.select do |key|
26
30
  @original[key] != self[key]
@@ -8,6 +8,10 @@ module ActiveRedis
8
8
  false
9
9
  end
10
10
 
11
+ def blank?
12
+ true
13
+ end
14
+
11
15
  def inspect
12
16
  "nil"
13
17
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveRedis
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -2,10 +2,11 @@ require "active_redis_orm"
2
2
 
3
3
  describe ActiveRedis do
4
4
  class AttributesObject < ActiveRedis::Base
5
- attr_accessible :foo, :bar, :list
5
+ attr_accessible :foo, :bar, :list, :string
6
6
  field :foo, default: lambda{|item| item.id}
7
7
  field :bar, default: "barbar"
8
- field :list
8
+ field :string
9
+ field :list, type: :list
9
10
  end
10
11
 
11
12
  it "deals with attributes in string or symbol implementation" do
@@ -14,8 +15,22 @@ describe ActiveRedis do
14
15
  end
15
16
 
16
17
  it "sets the defaults" do
17
- item = AttributesObject.create(list: "123")
18
+ item = AttributesObject.create(string: "123")
18
19
  item.foo.should == item.id
19
20
  item.bar.should == "barbar"
20
21
  end
22
+
23
+ context "lists" do
24
+ it "is dirty only when dirty" do
25
+ instance = AttributesObject.new
26
+ instance.string = "abc"
27
+ instance.save
28
+
29
+ instance.list << "a"
30
+ instance.save
31
+ instance.list.should_not be_dirty
32
+ instance.should_not be_dirty
33
+ instance.reload!.list.should == ["a"]
34
+ end
35
+ end
21
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_redis_orm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Caspy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-02 00:00:00.000000000 Z
11
+ date: 2014-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler