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(
2828 end
2929
3030 # 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!
3333 end
3434
3535 BLANK = Blank . new
Original file line number Diff line number Diff line change @@ -936,4 +936,11 @@ class JbuilderTest < ActiveSupport::TestCase
936936 result = JSON . load ( Jbuilder . encode { |json | json . time Time . parse ( "2018-05-13 11:51:00.485 -0400" ) } )
937937 assert_equal "2018-05-13T11:51:00.485-04:00" , result [ "time" ]
938938 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
939946end
You can’t perform that action at this time.
0 commit comments