redis_assist 0.4.3 → 0.4.4
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 +15 -7
- data/lib/redis_assist/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fca3422e9a8b3aa9e52ec50f8375e7e15a17195
|
4
|
+
data.tar.gz: 92852c0ed3f94342753e0f34a96acfbe6a645d3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05a45f208034e395f255814ee7a466a7bb8a811438f5216f2179e9d493f2af4d20d8bc9c512c0003519e027e438336403fe7f1d7b7a83223a3e25f59976ab985
|
7
|
+
data.tar.gz: 69194d125abf3d9f3bbfdf5da1bf8075f3b38c6a58578b5d09bd2daf915ecd6788bffa1c99d2f60ec2d4569ef9afdc0f04ee6691ba6971b31160454ce3c56261
|
data/lib/redis_assist/base.rb
CHANGED
@@ -209,16 +209,11 @@ module RedisAssist
|
|
209
209
|
|
210
210
|
def define_attribute(name)
|
211
211
|
define_method(name) do
|
212
|
-
|
213
|
-
value = attributes.value
|
214
|
-
self.attributes = value ? Hash[*self.class.fields.keys.zip(value).flatten] : {}
|
215
|
-
end
|
216
|
-
|
217
|
-
self.class.transform(:from, name, attributes[name])
|
212
|
+
read_attribute(name)
|
218
213
|
end
|
219
214
|
|
220
215
|
define_method("#{name}=") do |val|
|
221
|
-
|
216
|
+
write_attribute(name, val)
|
222
217
|
end
|
223
218
|
end
|
224
219
|
end
|
@@ -251,6 +246,19 @@ module RedisAssist
|
|
251
246
|
|
252
247
|
raise "RedisAssist: #{self.class.name} does not support attributes: #{attrs.keys.join(', ')}" if attrs.length > 0
|
253
248
|
end
|
249
|
+
|
250
|
+
def read_attribute(name)
|
251
|
+
if attributes.is_a?(Redis::Future)
|
252
|
+
value = attributes.value
|
253
|
+
self.attributes = value ? Hash[*self.class.fields.keys.zip(value).flatten] : {}
|
254
|
+
end
|
255
|
+
|
256
|
+
self.class.transform(:from, name, attributes[name])
|
257
|
+
end
|
258
|
+
|
259
|
+
def write_attribute(name, val)
|
260
|
+
attributes[name] = self.class.transform(:to, name, val)
|
261
|
+
end
|
254
262
|
|
255
263
|
def saved?
|
256
264
|
!!(new_record?.eql?(false) && id)
|
data/lib/redis_assist/version.rb
CHANGED