ohm 3.1.0 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gems +1 -1
- data/CHANGELOG.md +6 -0
- data/lib/ohm.rb +10 -5
- data/ohm.gemspec +1 -1
- data/test/model.rb +20 -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: c14f3b614b87065690df7178044108141a7d056e
|
4
|
+
data.tar.gz: dc6fcb2dfb315d0802828269c5b412ce623060b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd5d4210c0bdba7c564eda8af923d48034452f7fe0ff3b04ff828cc06cb13f5ce3f541161b67fec2404a908facd9495843c8532f929cfb4d1a911f15ac2580fa
|
7
|
+
data.tar.gz: 777c1de3589c60f6d32ce53ab464fc0a952df4f35593119bc01a1d5add324acfde7913348c3a540ab8cb2e4991641dd74b269f30c80f1ed1f888be5a6abeeb82
|
data/.gems
CHANGED
data/CHANGELOG.md
CHANGED
data/lib/ohm.rb
CHANGED
@@ -1108,9 +1108,7 @@ module Ohm
|
|
1108
1108
|
# u = User.new(:name => "John")
|
1109
1109
|
#
|
1110
1110
|
def initialize(atts = {})
|
1111
|
-
|
1112
|
-
@_memo = {}
|
1113
|
-
update_attributes(atts)
|
1111
|
+
reload_attributes(atts)
|
1114
1112
|
end
|
1115
1113
|
|
1116
1114
|
# Access the ID used to store this model. The ID is used together
|
@@ -1143,10 +1141,17 @@ module Ohm
|
|
1143
1141
|
# Preload all the attributes of this model from Redis. Used
|
1144
1142
|
# internally by `Model::[]`.
|
1145
1143
|
def load!
|
1146
|
-
|
1144
|
+
reload_attributes(Utils.dict(key.call("HGETALL"))) unless new?
|
1147
1145
|
return self
|
1148
1146
|
end
|
1149
1147
|
|
1148
|
+
# Reset the attributes table and load the passed values.
|
1149
|
+
def reload_attributes(atts = {})
|
1150
|
+
@attributes = {}
|
1151
|
+
@_memo = {}
|
1152
|
+
update_attributes(atts)
|
1153
|
+
end
|
1154
|
+
|
1150
1155
|
# Read an attribute remotely from Redis. Useful if you want to get
|
1151
1156
|
# the most recent value of the attribute and not rely on locally
|
1152
1157
|
# cached value.
|
@@ -1375,7 +1380,7 @@ module Ohm
|
|
1375
1380
|
script(LUA_DELETE, 0,
|
1376
1381
|
{ "name" => model.name,
|
1377
1382
|
"id" => id,
|
1378
|
-
"key" => key
|
1383
|
+
"key" => key.to_s
|
1379
1384
|
}.to_json,
|
1380
1385
|
uniques.to_json,
|
1381
1386
|
model.tracked.to_json
|
data/ohm.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "ohm"
|
3
|
-
s.version = "3.1.
|
3
|
+
s.version = "3.1.1"
|
4
4
|
s.summary = %{Object-hash mapping library for Redis.}
|
5
5
|
s.description = %Q{Ohm is a library that allows to store an object in Redis, a persistent key-value database. It has very good performance.}
|
6
6
|
s.authors = ["Michel Martens", "Damian Janowski", "Cyril David"]
|
data/test/model.rb
CHANGED
@@ -123,6 +123,26 @@ test "updates attributes" do
|
|
123
123
|
assert "Ruby Meetup" == event.name
|
124
124
|
end
|
125
125
|
|
126
|
+
test "reload attributes" do
|
127
|
+
event1 = Meetup.create(:name => "Foo", :location => "Bar")
|
128
|
+
event2 = Meetup[event1.id]
|
129
|
+
|
130
|
+
assert_equal "Foo", event1.name
|
131
|
+
assert_equal "Bar", event1.location
|
132
|
+
|
133
|
+
assert_equal "Foo", event2.name
|
134
|
+
assert_equal "Bar", event2.location
|
135
|
+
|
136
|
+
event1.update(:name => nil)
|
137
|
+
event2.load!
|
138
|
+
|
139
|
+
assert_equal nil, event1.name
|
140
|
+
assert_equal "Bar", event1.location
|
141
|
+
|
142
|
+
assert_equal nil, event2.name
|
143
|
+
assert_equal "Bar", event2.location
|
144
|
+
end
|
145
|
+
|
126
146
|
test "save the attributes in UTF8" do
|
127
147
|
event = Meetup.create(:name => "32° Kisei-sen")
|
128
148
|
assert "32° Kisei-sen" == Meetup[event.id].name
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ohm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michel Martens
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-12-
|
13
|
+
date: 2016-12-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: redic
|