ohm 3.1.0 → 3.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (7) hide show
  1. checksums.yaml +4 -4
  2. data/.gems +1 -1
  3. data/CHANGELOG.md +6 -0
  4. data/lib/ohm.rb +10 -5
  5. data/ohm.gemspec +1 -1
  6. data/test/model.rb +20 -0
  7. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65d8dd7c7555b0a26c8f4eb8845c08354b174acc
4
- data.tar.gz: b12b6410534f2031ae211eff20604e9ac6da4473
3
+ metadata.gz: c14f3b614b87065690df7178044108141a7d056e
4
+ data.tar.gz: dc6fcb2dfb315d0802828269c5b412ce623060b2
5
5
  SHA512:
6
- metadata.gz: 322e82928c55dc4fbaa9a370220c8e7c0bc382ef4a709fd96456add67a4b26f56617f7f54af4c5a3c14af59fc27fe50fa0ad6339db9246be7c1bee87fa743ddd
7
- data.tar.gz: dbf21bd5c4984b2d6cbbb8c379aa88696c0a2a154d1fcf5cccfad35ca2e24856d223bb6e3b4642c556b163e82ae344e1cf9d45e2fcfe5b625aca6ef8b5c36d3f
6
+ metadata.gz: dd5d4210c0bdba7c564eda8af923d48034452f7fe0ff3b04ff828cc06cb13f5ce3f541161b67fec2404a908facd9495843c8532f929cfb4d1a911f15ac2580fa
7
+ data.tar.gz: 777c1de3589c60f6d32ce53ab464fc0a952df4f35593119bc01a1d5add324acfde7913348c3a540ab8cb2e4991641dd74b269f30c80f1ed1f888be5a6abeeb82
data/.gems CHANGED
@@ -1,4 +1,4 @@
1
1
  nest -v 3.0.0
2
2
  redic -v 1.5.0
3
- stal -v 0.1.0
4
3
  cutest -v 1.2.3
4
+ stal -v 0.3.0
@@ -1,3 +1,9 @@
1
+ ## 3.1.1
2
+
3
+ - Serialize keys as strings when using JSON.
4
+
5
+ - Reset attributes when calling `load!`.
6
+
1
7
  ## 3.1.0
2
8
 
3
9
  - Use Nest instead of Nido
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
- @attributes = {}
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
- update_attributes(Utils.dict(key.call("HGETALL"))) unless new?
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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "ohm"
3
- s.version = "3.1.0"
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"]
@@ -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.0
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-03 00:00:00.000000000 Z
13
+ date: 2016-12-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: redic