Sha256: 888cbe3d9c89756ed0f10c94e2edcb5b07bd41729faca17bf990d2286ebc17c7

Contents?: true

Size: 893 Bytes

Versions: 40

Compression:

Stored size: 893 Bytes

Contents

# run me with bundle exec ruby -Itest test/example.rb

require "test_helper"

ActiveRecord::Base.logger = Logger.new(STDOUT)

module Twin
  class Album < Disposable::Twin
    property :id # DISCUSS: needed for #save.
    property :name
    collection :songs, :twin => lambda { |*| Song }

    extend Representer
    include Setup
    include Sync
  end

  class Song < Disposable::Twin
    property :id # DISCUSS: needed for #save.
    property :title
    # property :album, :twin => Album

    extend Representer
    include Setup
    include Sync
  end
end

album = Album.last

twin = Twin::Album.new(album)
puts "existing songs (#{twin.songs.size}): #{twin.songs.inspect}"

# this is what basically should happen in the representer, returning a Twin.
twin.songs << Song.new
twin.songs.last.title = "Back To Allentown"

puts "new songs (#{twin.songs.size}): #{twin.songs.inspect}"

twin.sync

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
disposable-0.6.3 test/example.rb
disposable-0.6.2 test/example.rb
disposable-0.6.1 test/example.rb
disposable-0.6.0 test/example.rb
disposable-0.5.0 test/example.rb
disposable-0.4.7 test/example.rb
disposable-0.4.6 test/example.rb
disposable-0.4.5 test/example.rb
disposable-0.4.4 test/example.rb
disposable-0.4.3 test/example.rb
disposable-0.4.2 test/example.rb
disposable-0.4.1 test/example.rb
disposable-0.4.0 test/example.rb
disposable-0.3.2 test/example.rb
disposable-0.3.1 test/example.rb
disposable-0.3.0 test/example.rb
disposable-0.2.6 test/example.rb
disposable-0.2.5 test/example.rb
disposable-0.2.4 test/example.rb
disposable-0.2.3 test/example.rb