active_redis_orm 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_redis/attributes.rb +31 -7
- data/lib/active_redis/version.rb +1 -1
- data/lib/active_redis_orm.rb +1 -0
- data/spec/lib/active_redis_spec.rb +19 -0
- 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: cc835df89e4be39ac1b69d89ab593d5ce757456f
|
4
|
+
data.tar.gz: 254047a9457bd3046c12222df4758f80127b2cc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c803373333f64291d1574ffc25ed5728635ad50d371b2c60e71cdd8922bd669e6e0f59e6cdffae2f60e3885ffc8bfdbce03ae22d29653b5b21d546cd93a5add
|
7
|
+
data.tar.gz: c478976912aad60b089831533e9c87a694e684e1b735a33faad9de3bedde4c905aae67ab267afca5feabd7c77b75f73a80293a4edec5976a81f2a04c7fe4de3f
|
@@ -98,11 +98,17 @@ module ActiveRedis
|
|
98
98
|
|
99
99
|
def #{field_name}=(value)
|
100
100
|
#{field_name}_will_change!
|
101
|
+
value = ActiveRedis::NilObject.new if value.nil?
|
101
102
|
@attributes[:#{field_name}] = value
|
102
103
|
end
|
103
104
|
|
104
105
|
def set_#{field_name}(value)
|
105
|
-
|
106
|
+
val = value.last
|
107
|
+
if val.nil?
|
108
|
+
destroy_#{field_name}
|
109
|
+
else
|
110
|
+
#{field_name}_object.value = val
|
111
|
+
end
|
106
112
|
after_set(:#{field_name})
|
107
113
|
end
|
108
114
|
}
|
@@ -123,11 +129,20 @@ module ActiveRedis
|
|
123
129
|
|
124
130
|
def #{field_name}=(value)
|
125
131
|
#{field_name}_will_change!
|
126
|
-
|
132
|
+
if value.nil?
|
133
|
+
@attributes[:#{field_name}] = ActiveRedis::NilObject.new
|
134
|
+
else
|
135
|
+
@attributes[:#{field_name}] = value.to_i
|
136
|
+
end
|
127
137
|
end
|
128
138
|
|
129
139
|
def set_#{field_name}(value)
|
130
|
-
|
140
|
+
val = value.last
|
141
|
+
if val.nil?
|
142
|
+
destroy_#{field_name}
|
143
|
+
else
|
144
|
+
#{field_name}_object.value = val.to_i
|
145
|
+
end
|
131
146
|
after_set(:#{field_name})
|
132
147
|
end
|
133
148
|
}
|
@@ -148,11 +163,20 @@ module ActiveRedis
|
|
148
163
|
|
149
164
|
def #{field_name}=(value)
|
150
165
|
#{field_name}_will_change!
|
151
|
-
|
166
|
+
if value.nil?
|
167
|
+
@attributes[:#{field_name}] = ActiveRedis::NilObject.new
|
168
|
+
else
|
169
|
+
@attributes[:#{field_name}] = value.to_f
|
170
|
+
end
|
152
171
|
end
|
153
172
|
|
154
173
|
def set_#{field_name}(value)
|
155
|
-
|
174
|
+
val = value.last
|
175
|
+
if val.nil?
|
176
|
+
destroy_#{field_name}
|
177
|
+
else
|
178
|
+
#{field_name}_object.value = val.to_f
|
179
|
+
end
|
156
180
|
after_set(:#{field_name})
|
157
181
|
end
|
158
182
|
}
|
@@ -319,10 +343,10 @@ module ActiveRedis
|
|
319
343
|
def set_#{field_name}(value)
|
320
344
|
changes = value.first.last
|
321
345
|
changes[:additions].each do |addition|
|
322
|
-
|
346
|
+
self.#{field_name}_object[addition] = changes[:hash].key(addition)
|
323
347
|
end
|
324
348
|
changes[:drops].each do |drop|
|
325
|
-
|
349
|
+
self.#{field_name}_object.delete(drop)
|
326
350
|
end
|
327
351
|
after_set(:#{field_name})
|
328
352
|
end
|
data/lib/active_redis/version.rb
CHANGED
data/lib/active_redis_orm.rb
CHANGED
@@ -148,6 +148,25 @@ describe ActiveRedis do
|
|
148
148
|
object.hash.should == {"foo" => "bar"}
|
149
149
|
end
|
150
150
|
|
151
|
+
it "saves sorted sets correctly" do
|
152
|
+
object = ActiveRedisObject.new
|
153
|
+
object.sorted_set["goofy"] = 2
|
154
|
+
object.sorted_set["hola"] = 1
|
155
|
+
object.save
|
156
|
+
object.reload!
|
157
|
+
object.sorted_set.should == ["hola", "goofy"]
|
158
|
+
end
|
159
|
+
|
160
|
+
it "removes the field if it's set to nil" do
|
161
|
+
object = ActiveRedisObject.new
|
162
|
+
object.foo = "foo"
|
163
|
+
object.save
|
164
|
+
object.foo = nil
|
165
|
+
object.save
|
166
|
+
object.reload!
|
167
|
+
object.foo.should == nil
|
168
|
+
end
|
169
|
+
|
151
170
|
it "tracks changes well" do
|
152
171
|
object = ActiveRedisObject.new
|
153
172
|
object.hash = {}
|
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.0.
|
4
|
+
version: 0.0.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-07-
|
11
|
+
date: 2014-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|