Sha256: 824b58cc40e004171b619f043136a6a94ec0365e90bba5aa1325f618ed0e44f7
Contents?: true
Size: 685 Bytes
Versions: 2
Compression:
Stored size: 685 Bytes
Contents
class Memento::Session < ActiveRecord::Base self.table_name = "memento_sessions" has_many :states, :class_name => "Memento::State", :dependent => :delete_all, :order => "id DESC" belongs_to :user validates_presence_of :user def add_state(action_type, record) states.store(action_type, record) end def undo states.map(&:undo).inject(Memento::ResultArray.new) do |results, result| result.state.destroy if result.success? results << result end ensure destroy if states.count.zero? end def undo! transaction do undo.tap do |results| raise Memento::ErrorOnRewind if results.failed? end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
memento-0.3.7 | lib/memento/session.rb |
memento-0.3.6 | lib/memento/session.rb |