simple_record 1.4.7 → 1.4.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,6 +11,10 @@ module SimpleRecord
11
11
  obj = new
12
12
  for key, value in object
13
13
  next if key == 'json_class'
14
+ if key == 'id'
15
+ obj.id = value
16
+ next
17
+ end
14
18
  obj.set key, value
15
19
  end
16
20
  obj
@@ -23,6 +27,7 @@ module SimpleRecord
23
27
  end
24
28
 
25
29
  def to_json(*a)
30
+ # puts 'to_json called'
26
31
  result = {
27
32
  'json_class' => self.class.name,
28
33
  'id' => self.id
@@ -36,8 +41,9 @@ module SimpleRecord
36
41
  end
37
42
  # puts 'result[name]=' + result[name].inspect
38
43
  end
39
-
40
- result.to_json(*a)
44
+ ret = result.to_json(*a)
45
+ # puts 'ret=' + ret.inspect
46
+ return ret
41
47
  end
42
48
 
43
49
  end
data/test/test_json.rb CHANGED
@@ -36,13 +36,16 @@ class TestJson < TestBase
36
36
 
37
37
  models << mm
38
38
 
39
- jsoned = JSON.generate models
39
+ jsoned = models.to_json
40
40
  puts 'jsoned=' + jsoned
41
41
  unjsoned = JSON.parse jsoned
42
42
  puts 'unjsoned=' + unjsoned.inspect
43
43
  assert unjsoned.size == models.size
44
44
  assert unjsoned[0].name == mm.name
45
45
  assert unjsoned[0].age == mm.age
46
+ assert unjsoned[0].created.present?
47
+ assert unjsoned[0].id.present?
48
+ assert unjsoned[0].id == mm.id, "unjsoned.id=#{unjsoned[0].id}"
46
49
 
47
50
  t = Tester.new
48
51
  t2 = Tester.new
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_record
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 4
9
- - 7
10
- version: 1.4.7
9
+ - 8
10
+ version: 1.4.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Travis Reeder
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-07-22 00:00:00 -07:00
20
+ date: 2010-07-30 00:00:00 -07:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency