ohm 2.0.0.alpha1 → 2.0.0.alpha2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8e636620601ef7b7ea32c20094a7e4752f438d95
4
- data.tar.gz: 09eabd0899085d76c4d0ddb5fc037459f2b424da
3
+ metadata.gz: 8294935327780b3b34f3e4ab6f84b59332d0037b
4
+ data.tar.gz: 9159ad5202c945da06f36b3e8e0cdc49472d928b
5
5
  SHA512:
6
- metadata.gz: 2f5caab8eb261e8381c1c3ea8b9c36da0cc2adb0785bcd70dc2d6d128032d783e0c50e607888fe3f99ab89c097fe0056c11f911637755a10961ac3e19d156994
7
- data.tar.gz: 71f3247c75a69a7bc5f4452ab9bf4b70824110f6d4d439d5e1510ad7565bfd64f81ac5dd7d7354dbf136bb983e7919657e93f3b1810a8ed8ad9731941c19ab67
6
+ metadata.gz: 84a62af64f0e7ab94f443a7b47df0172154938d9c5c203a2921dbfa120950d69f81e43738853215069c7ef73c1f433a52327a971986290686b1e309fcac91d99
7
+ data.tar.gz: f69591ef5c027b9585570c03d831b5d839e6990d310bae4c469e8ed70de6124620e7b7d280bc689a180bb3b74af1d260138172f11d51c5fcd5a7443cae6ff6a4
data/lib/ohm.rb CHANGED
@@ -937,6 +937,8 @@ module Ohm
937
937
  reader = :"#{name}_id"
938
938
  writer = :"#{name}_id="
939
939
 
940
+ attributes << reader unless attributes.include?(reader)
941
+
940
942
  index reader
941
943
 
942
944
  define_method(reader) do
@@ -1238,16 +1240,12 @@ module Ohm
1238
1240
 
1239
1241
  _initialize_id if new?
1240
1242
 
1241
- attrs = attributes.delete_if do |k, v|
1242
- v.nil?
1243
- end
1244
-
1245
1243
  response = script(LUA_SAVE, 0,
1246
1244
  { "name" => model.name,
1247
1245
  "id" => id,
1248
1246
  "key" => key
1249
1247
  }.to_msgpack,
1250
- attrs.flatten.to_msgpack,
1248
+ _sanitized_attributes.to_msgpack,
1251
1249
  indices.to_msgpack,
1252
1250
  uniques.to_msgpack
1253
1251
  )
@@ -1391,5 +1389,19 @@ module Ohm
1391
1389
  def _initialize_id
1392
1390
  @id = model.new_id.to_s
1393
1391
  end
1392
+
1393
+ def _sanitized_attributes
1394
+ result = []
1395
+
1396
+ model.attributes.each do |field|
1397
+ val = send(field)
1398
+
1399
+ if val
1400
+ result.push(field, val.to_s)
1401
+ end
1402
+ end
1403
+
1404
+ return result
1405
+ end
1394
1406
  end
1395
1407
  end
data/lib/ohm/lua/save.lua CHANGED
@@ -78,21 +78,6 @@ if err then
78
78
  error("UniqueIndexViolation: " .. duplicates[1])
79
79
  end
80
80
 
81
- local function convertBooleans(list)
82
- for index, value in ipairs(list) do
83
- if type(value) == "boolean" then
84
- if value then
85
- list[index] = 1
86
- else
87
- list[index] = nil
88
- list[index - 1] = nil
89
- end
90
- end
91
- end
92
- end
93
-
94
- convertBooleans(attrs)
95
-
96
81
  save(model, attrs)
97
82
 
98
83
  remove_indices(model)
data/ohm.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "ohm"
3
- s.version = "2.0.0.alpha1"
3
+ s.version = "2.0.0.alpha2"
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 includes an extensible list of validations and has very good performance.}
6
6
  s.authors = ["Michel Martens", "Damian Janowski", "Cyril David"]
data/test/model.rb CHANGED
@@ -69,7 +69,7 @@ test "booleans" do
69
69
 
70
70
  post = Post[post.id]
71
71
 
72
- assert_equal "1", post.body
72
+ assert_equal "true", post.body
73
73
  assert_equal nil, post.published
74
74
  end
75
75
 
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: 2.0.0.alpha1
4
+ version: 2.0.0.alpha2
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: 2013-04-29 00:00:00.000000000 Z
13
+ date: 2013-04-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: redic
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  version: 1.3.1
141
141
  requirements: []
142
142
  rubyforge_project: ohm
143
- rubygems_version: 2.0.3
143
+ rubygems_version: 2.0.0
144
144
  signing_key:
145
145
  specification_version: 4
146
146
  summary: Object-hash mapping library for Redis.