File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -28,8 +28,8 @@ def initialize(
28
28
end
29
29
30
30
# Yields a builder and automatically turns the result into a JSON string
31
- def self . encode ( * args , & block )
32
- new ( * args , & block ) . target!
31
+ def self . encode ( ... )
32
+ new ( ... ) . target!
33
33
end
34
34
35
35
BLANK = Blank . new
Original file line number Diff line number Diff line change @@ -936,4 +936,11 @@ class JbuilderTest < ActiveSupport::TestCase
936
936
result = JSON . load ( Jbuilder . encode { |json | json . time Time . parse ( "2018-05-13 11:51:00.485 -0400" ) } )
937
937
assert_equal "2018-05-13T11:51:00.485-04:00" , result [ "time" ]
938
938
end
939
+
940
+ test "encode forwards options to new" do
941
+ Jbuilder . encode ( key_formatter : 1 , ignore_nil : 2 ) do |json |
942
+ assert_equal 1 , json . instance_eval { @key_formatter }
943
+ assert_equal 2 , json . instance_eval { @ignore_nil }
944
+ end
945
+ end
939
946
end
You can’t perform that action at this time.
0 commit comments