Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/disposable/twin/property/hash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def self.included(includer)
if options[:_nested_builder] # DISCUSS: any other way to figure out we're nested?
Hash.hash_options
else
{ }
{ render_nil: true }
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions test/twin/hash_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Song < Disposable::Twin

song.sync

model.inspect.must_equal "#<struct HashTest::Model id=nil, content={\"band\"=>{\"label\"=>{\"location\"=>\"San Francisco\"}}, \"releases\"=>[]}>"
model.inspect.must_equal "#<struct HashTest::Model id=nil, content={\"title\"=>nil, \"band\"=>{\"name\"=>nil, \"label\"=>{\"location\"=>\"San Francisco\"}}, \"releases\"=>[]}>"
end

it "#appends to collections" do
Expand All @@ -76,7 +76,7 @@ class Song < Disposable::Twin

song.sync

model.inspect.must_equal "#<struct HashTest::Model id=nil, content={\"band\"=>{\"label\"=>{}}, \"releases\"=>[{\"version\"=>1}]}>"
model.inspect.must_equal "#<struct HashTest::Model id=nil, content={\"title\"=>nil, \"band\"=>{\"name\"=>nil, \"label\"=>{\"location\"=>nil}}, \"releases\"=>[{\"version\"=>1}]}>"
end

it "doesn't erase existing, undeclared content" do
Expand All @@ -88,7 +88,7 @@ class Song < Disposable::Twin
# puts song.content.class.ancestors
song.sync

model.inspect.must_equal "#<struct HashTest::Model id=nil, content={\"artist\"=>{}, \"band\"=>{\"label\"=>{\"location\"=>\"San Francisco\"}}, \"releases\"=>[]}>"
model.inspect.must_equal "#<struct HashTest::Model id=nil, content={\"artist\"=>{}, \"title\"=>nil, \"band\"=>{\"name\"=>nil, \"label\"=>{\"location\"=>\"San Francisco\"}}, \"releases\"=>[]}>"
end

it "doesn't erase existing, undeclared content in existing content" do
Expand All @@ -99,7 +99,7 @@ class Song < Disposable::Twin

song.sync

model.inspect.must_equal "#<struct HashTest::Model id=nil, content={\"band\"=>{\"label\"=>{\"owner\"=>\"Brett Gurewitz\", \"location\"=>\"San Francisco\"}, \"genre\"=>\"Punkrock\"}, \"releases\"=>[]}>"
model.inspect.must_equal "#<struct HashTest::Model id=nil, content={\"band\"=>{\"label\"=>{\"owner\"=>\"Brett Gurewitz\", \"location\"=>\"San Francisco\"}, \"genre\"=>\"Punkrock\", \"name\"=>nil}, \"title\"=>nil, \"releases\"=>[]}>"
end


Expand Down