-
-
Save matthewford/18338 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#how i'd imagine this working, and how to just deal with the ticket obj, although just tested and this doesn't quite work. will see if i can fix it tomorrow | |
class Ticket < Sequel::Model | |
set_schema do | |
foreign_key :ticket_detail_id, :table => :ticket_detail | |
# integer :ticket_detail_version | |
end | |
is(:versioned_fact, {:dimensions => [TicketDetail]}) | |
one_to_many :ticket_details | |
def name | |
self.current_detail.name | |
end | |
def name=(n) | |
self.current_detail.name = n | |
end | |
# this could added to the plugin actually | |
before_save do | |
self.current_detail.save | |
end | |
end | |
class TicketDetail < Sequel::Model | |
set_schema do | |
foreign_key :ticket_id, :table => :tickets | |
#varchar :name | |
end | |
is :versioned_object | |
many_to_one :ticket | |
end | |
tic = Ticket.create | |
tic.name = "version 0" | |
tic.save | |
tic.version! | |
tic.name = "version 1" | |
tic.save | |
puts tic.name.should == "version 1" | |
tic.fetch_version = 0 | |
puts tic.name.should == "version 0" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment