Skip to content

Instantly share code, notes, and snippets.

@matthewford
Forked from fairchild/gist:18334
Created October 21, 2008 16:14
Show Gist options
  • Save matthewford/18338 to your computer and use it in GitHub Desktop.
Save matthewford/18338 to your computer and use it in GitHub Desktop.
#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