jam-ruby 0.0.7 → 0.0.8

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.
Files changed (3) hide show
  1. data/README.rdoc +4 -4
  2. data/lib/jam/builder.rb +12 -3
  3. metadata +4 -4
data/README.rdoc CHANGED
@@ -69,16 +69,16 @@ Works like in Rails to_json:
69
69
 
70
70
  object @post, :root => :bost
71
71
 
72
- [Other examples](https://github.com/edtsech/jam/tree/master/examples)
72
+ Other examples[link:https://github.com/edtsech/jam/tree/master/examples]
73
73
 
74
74
  == Contributions
75
75
 
76
- We open for you contributions, sugesstions and ideas.
76
+ We open for you contributions, suggestions and ideas.
77
77
 
78
78
  == Inspired by
79
79
 
80
- - Tequila
81
- - Rabl
80
+ - Tequila[link:https://github.com/inem/tequila]
81
+ - Rabl[link:https://github.com/nesquena/rabl]
82
82
 
83
83
  Some of code was borrowed from RABL.
84
84
 
data/lib/jam/builder.rb CHANGED
@@ -45,12 +45,21 @@ module Jam
45
45
 
46
46
  result = {}
47
47
 
48
- result.merge!(obj.as_json(options))
49
-
50
48
  if block
49
+ options[:only] ||= [:id]
50
+
51
51
  blk = block.call(obj).stringify_keys
52
52
  result.merge!(blk) unless root
53
- result[root].merge!(blk) if root
53
+ result[root] = blk if root
54
+ end
55
+
56
+ as_json_res = obj.as_json(options)
57
+
58
+ if root
59
+ result[root] ||= {}
60
+ result[root].reverse_merge! as_json_res[root]
61
+ else
62
+ result.reverse_merge! as_json_res
54
63
  end
55
64
 
56
65
  result.stringify_keys
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jam-ruby
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 7
10
- version: 0.0.7
9
+ - 8
10
+ version: 0.0.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Edward Tsech
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-07-17 00:00:00 +07:00
18
+ date: 2011-07-19 00:00:00 +07:00
19
19
  default_executable:
20
20
  dependencies: []
21
21