jbuilder 2.0.0.beta → 2.0.0.beta2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3abb8f97fbc68d58021fc1c5bc66fec71d338da7
4
- data.tar.gz: 1f5eac2118e6f0762d41d7b6ce1ea559a10feca9
3
+ metadata.gz: 2b0b628cdf50af7a4e659568d35ff32f8012c95f
4
+ data.tar.gz: b11afc7dbd0b7dde47149238490f8599dc0e1d80
5
5
  SHA512:
6
- metadata.gz: fe7ee8dc65453809938c89bfd35f037ae6113e30f648eb66da2ab844bd9dc0574a9c79c381198ec667077dd648cb30946cf81d433085ff31de2d8acba45a00bd
7
- data.tar.gz: bcbf4fa794515f477a809d33b18b9ac7e9df227f3fbe1f708bea2f1b1f90d340439f783ff96f1b40c413c9ec539703f267745183761d9c3d8e945f3288ae20ce
6
+ metadata.gz: a1809fd60109a55c20893f0349837c809e83892d3b0e116a280b1cac9bf493c0902ad43ede7b5530b12daae854349ba03194056b0d3e3ae0b9803604ac6be461
7
+ data.tar.gz: aa8981b12fdf1783a9d9607d4320191c873b0cdd4de0038c90163bd88977ab82cbdbc32fb224187a5a3cd699762431fd422b23e34854420f6a8e84c97ec9a4a2
data/README.md CHANGED
@@ -204,4 +204,4 @@ Libraries similar to this in some form or another include:
204
204
  * JsonBuilder: https://github.com/nov/jsonbuilder
205
205
  * JSON Builder: https://github.com/dewski/json_builder
206
206
  * Jsonify: https://github.com/bsiggelkow/jsonify
207
- * RepresentationView: https://github.com/mdub/representative_view
207
+ * Representative View: https://github.com/mdub/representative_view
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'jbuilder'
3
- s.version = '2.0.0.beta'
3
+ s.version = '2.0.0.beta2'
4
4
  s.author = 'David Heinemeier Hansson'
5
5
  s.email = 'david@37signals.com'
6
6
  s.summary = 'Create JSON structures via a Builder-style DSL'
@@ -24,6 +24,10 @@ module Rails
24
24
 
25
25
 
26
26
  protected
27
+ def attributes_names
28
+ [:id] + super
29
+ end
30
+
27
31
  def filename_with_extensions(name)
28
32
  [name, :json, :jbuilder] * '.'
29
33
  end
@@ -273,6 +273,16 @@ class Jbuilder < JbuilderProxy
273
273
  @attributes
274
274
  end
275
275
 
276
+ # Merges hash or array into current builder.
277
+ def merge!(hash_or_array)
278
+ if ::Array === hash_or_array
279
+ @attributes = [] unless ::Array === @attributes
280
+ @attributes.concat hash_or_array
281
+ else
282
+ @attributes.update hash_or_array
283
+ end
284
+ end
285
+
276
286
  # Encodes the current builder as JSON.
277
287
  def target!
278
288
  ::MultiJson.dump(@attributes)
@@ -312,15 +322,6 @@ class Jbuilder < JbuilderProxy
312
322
  @attributes, @key_formatter = parent_attributes, parent_formatter
313
323
  end
314
324
 
315
- def _merge(hash_or_array)
316
- if ::Array === hash_or_array
317
- @attributes = [] unless ::Array === @attributes
318
- @attributes.concat hash_or_array
319
- else
320
- @attributes.update hash_or_array
321
- end
322
- end
323
-
324
325
  def _mapable_arguments?(value, *args)
325
326
  value.respond_to?(:map)
326
327
  end
@@ -54,7 +54,7 @@ class JbuilderTemplate < Jbuilder
54
54
  _scope { yield self }
55
55
  end
56
56
 
57
- _merge(value)
57
+ merge! value
58
58
  else
59
59
  yield
60
60
  end
@@ -20,12 +20,12 @@ class JbuilderGeneratorTest < Rails::Generators::TestCase
20
20
 
21
21
  assert_file 'app/views/posts/index.json.jbuilder' do |content|
22
22
  assert_match /json\.array!\(@posts\) do \|post\|/, content
23
- assert_match /json\.extract! post, :title, :body/, content
23
+ assert_match /json\.extract! post, :id, :title, :body/, content
24
24
  assert_match /json\.url post_url\(post, format: :json\)/, content
25
25
  end
26
26
 
27
27
  assert_file 'app/views/posts/show.json.jbuilder' do |content|
28
- assert_match /json\.extract! @post, :title, :body, :created_at, :updated_at/, content
28
+ assert_match /json\.extract! @post, :id, :title, :body, :created_at, :updated_at/, content
29
29
  end
30
30
  end
31
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jbuilder
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.beta
4
+ version: 2.0.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-24 00:00:00.000000000 Z
11
+ date: 2013-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  version: 1.3.1
87
87
  requirements: []
88
88
  rubyforge_project:
89
- rubygems_version: 2.1.5
89
+ rubygems_version: 2.0.14
90
90
  signing_key:
91
91
  specification_version: 4
92
92
  summary: Create JSON structures via a Builder-style DSL
@@ -96,4 +96,3 @@ test_files:
96
96
  - test/jbuilder_template_test.rb
97
97
  - test/jbuilder_test.rb
98
98
  - test/scaffold_controller_generator_test.rb
99
- has_rdoc: