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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 054bac42e4c1e0f4adba522333b55fd65a3e8429
4
- data.tar.gz: 05f6aab4da5a3f3c990ffffaad2393062f1502b4
3
+ metadata.gz: 3fca3422e9a8b3aa9e52ec50f8375e7e15a17195
4
+ data.tar.gz: 92852c0ed3f94342753e0f34a96acfbe6a645d3a
5
5
  SHA512:
6
- metadata.gz: 6b4d0048735020ba22db5cecf7cc6fd83a481de31fef5c6ea7e7cb8e612324b1c1c9efb9885f1b27bc11f7bf86bd94e5bd4e7b05df4d7ced148b8a78cc140b82
7
- data.tar.gz: 52507d58282d85038d24ded5fd13bcd1b8bd0fb030c7f51bdf0e6321345a43467fa6c7fd444a44b2acf29c8eed391ce88e576cde70563189cda44cfbdfad1956
6
+ metadata.gz: 05a45f208034e395f255814ee7a466a7bb8a811438f5216f2179e9d493f2af4d20d8bc9c512c0003519e027e438336403fe7f1d7b7a83223a3e25f59976ab985
7
+ data.tar.gz: 69194d125abf3d9f3bbfdf5da1bf8075f3b38c6a58578b5d09bd2daf915ecd6788bffa1c99d2f60ec2d4569ef9afdc0f04ee6691ba6971b31160454ce3c56261
@@ -209,16 +209,11 @@ module RedisAssist
209
209
 
210
210
  def define_attribute(name)
211
211
  define_method(name) do
212
- if attributes.is_a?(Redis::Future)
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
- attributes[name] = self.class.transform(:to, name, val)
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)
@@ -1,3 +1,3 @@
1
1
  module RedisAssist
2
- VERSION = '0.4.3' unless defined?(::RedisAssist::VERSION)
2
+ VERSION = '0.4.4' unless defined?(::RedisAssist::VERSION)
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis_assist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Love