jbuilder 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- N2YxYTRjN2IyZGNkNDA0NTljMWNhODk1ZDQ3NjUyOTRjZDg5ZWM0MQ==
4
+ MmU0OWNkNDE0NGQzMWFiNmU2N2ZiOTY2NjA1MTk5ZDg3YTYyMmJiYQ==
5
5
  data.tar.gz: !binary |-
6
- NGEyOTdjNmFmMDdkMTAyNTk2ZDRmZTI4MDkwNTM4MjE0MDVlODQzNA==
6
+ N2Q5YjE3Mjk4ZThjZTU1NGQxY2QwZGQzZjJhOTliZTU3MDA2M2VmMQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NTU3NGJmNzM1NGU2Nzg4ZGY1ZWRlNmY1MTU3YjhiZDk0YWFhNzU3NTk5ODhi
10
- OTI0YjVjNGQ1NTRhMTgwZTFmNzM2ZDM2MTQyMGU1YjBlYzE2NjBmMzdkOWIw
11
- Zjg5ODhkNjQ2MDVkZDkzZGFlY2I4NGE3YWRjZjE3OWY2ZmY4OTA=
9
+ MmYxNDMwNTAzZjI5ZDIzY2U1M2RjYjAxOTUwZDBiNzlmNjMyYTNkN2JhZWY3
10
+ OTE4NmQzMmVjZWE2YmJkYjg1NzEyNWYyYjcyMGQ1MDYxMDc1YzkxYmRlZjEw
11
+ ZDQwZDdhZjViYWQ2YmZkNDhiNTI1YzYwYjc3YjQ0NWE5ZTIyOTQ=
12
12
  data.tar.gz: !binary |-
13
- NzkxMWVmNGYxNDJhZDM3ODg0ZGU1MTE2MzI5Yjg1NTFhOTQ5NTJhOTY0MmY1
14
- YzFjYTE4M2I3NWI0ZjE4ZDlhZjZjYjRjODUwN2YyYTE0YjYwOGU4NjNlNDg3
15
- MmMxZTM0ZjlkODkzYzY0MGQ1M2RlNGQwNWRhNWE5ODYwZWU4M2E=
13
+ NDg5NmI2ZjhiN2UyYjU4MjhhZGRiNGYzZDU4ZjBkOWQ5NTVmYzhjYjQwZmIy
14
+ MzYxZmMzMWJmMTdkMjM2YzdhNjk0ZGJjMGNmMTBhYWQ5MDI3M2VlODczNWQ3
15
+ ODE2MWQzOWU5NTZkYjI0MmRhNTk2MDk5YTUyOWZkYzgwYzRjYWQ=
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'jbuilder'
3
- s.version = '1.2.1'
3
+ s.version = '1.3.0'
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'
@@ -73,6 +73,7 @@ class Jbuilder < JbuilderProxy
73
73
  BLANK = ::Object.new
74
74
 
75
75
  def set!(key, value = BLANK, *args, &block)
76
+
76
77
  result = if ::Kernel.block_given?
77
78
  if BLANK != value
78
79
  # json.comments @post.comments { |comment| ... }
@@ -256,6 +257,14 @@ class Jbuilder < JbuilderProxy
256
257
  end
257
258
  end
258
259
 
260
+ # Returns the nil JSON.
261
+ def nil!
262
+ @attributes = nil
263
+ end
264
+
265
+ alias_method :null!, :nil!
266
+
267
+
259
268
  def call(object = nil, *attributes)
260
269
  if attributes.empty?
261
270
  array! object, &::Proc.new
@@ -310,4 +319,4 @@ class Jbuilder < JbuilderProxy
310
319
  end
311
320
 
312
321
  require 'jbuilder/jbuilder_template' if defined?(ActionView::Template)
313
- require 'jbuilder/railtie' if defined?(Rails::VERSION::MAJOR) && Rails::VERSION::MAJOR == 4
322
+ require 'jbuilder/railtie' if defined?(Rails::VERSION::MAJOR) && Rails::VERSION::MAJOR == 4
@@ -571,4 +571,18 @@ class JbuilderTest < ActiveSupport::TestCase
571
571
  assert_equal ['name'], json.attributes!.keys
572
572
  Jbuilder.send(:class_variable_set, '@@ignore_nil', false)
573
573
  end
574
+
575
+ test 'nil!' do
576
+ json = Jbuilder.new
577
+ json.key 'value'
578
+ json.nil!
579
+ assert_nil json.attributes!
580
+ end
581
+
582
+ test 'null!' do
583
+ json = Jbuilder.new
584
+ json.key 'value'
585
+ json.null!
586
+ assert_nil json.attributes!
587
+ end
574
588
  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: 1.2.1
4
+ version: 1.3.0
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-04-09 00:00:00.000000000 Z
11
+ date: 2013-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  prerelease: false