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 +8 -8
- data/jbuilder.gemspec +1 -1
- data/lib/jbuilder.rb +10 -1
- data/test/jbuilder_test.rb +14 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MmU0OWNkNDE0NGQzMWFiNmU2N2ZiOTY2NjA1MTk5ZDg3YTYyMmJiYQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
N2Q5YjE3Mjk4ZThjZTU1NGQxY2QwZGQzZjJhOTliZTU3MDA2M2VmMQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MmYxNDMwNTAzZjI5ZDIzY2U1M2RjYjAxOTUwZDBiNzlmNjMyYTNkN2JhZWY3
|
10
|
+
OTE4NmQzMmVjZWE2YmJkYjg1NzEyNWYyYjcyMGQ1MDYxMDc1YzkxYmRlZjEw
|
11
|
+
ZDQwZDdhZjViYWQ2YmZkNDhiNTI1YzYwYjc3YjQ0NWE5ZTIyOTQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDg5NmI2ZjhiN2UyYjU4MjhhZGRiNGYzZDU4ZjBkOWQ5NTVmYzhjYjQwZmIy
|
14
|
+
MzYxZmMzMWJmMTdkMjM2YzdhNjk0ZGJjMGNmMTBhYWQ5MDI3M2VlODczNWQ3
|
15
|
+
ODE2MWQzOWU5NTZkYjI0MmRhNTk2MDk5YTUyOWZkYzgwYzRjYWQ=
|
data/jbuilder.gemspec
CHANGED
data/lib/jbuilder.rb
CHANGED
@@ -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
|
data/test/jbuilder_test.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2013-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
prerelease: false
|