Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose Disposable::Twin#build_twin via Disposable::Twin::Collection#new #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
5 changes: 5 additions & 0 deletions lib/disposable/twin/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ def save # only gets called when Collection::Semantics mixed in.
destroy!
end

# Twins a model
def new(model)
@twinner.(model)
end

module Changed
# FIXME: this should not be included automatically, as Changed is a feature.
def changed?
Expand Down
9 changes: 9 additions & 0 deletions test/twin/collection_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,15 @@ class Album < Disposable::Twin
twin.songs.deleted.must_equal []
end
end

describe "#new" do
let (:album) { Album.create() }

it do
twin = Twin::Album.new(album)
twin.songs.new(Song.new).must_be_instance_of Twin::Song
end
end
end


Expand Down