Sha256: 72af7a7ba32ee819b1b38b36575b1843201df9ca20dab62de890875960faba30
Contents?: true
Size: 758 Bytes
Versions: 2
Compression:
Stored size: 758 Bytes
Contents
module Memento class Session < ActiveRecord::Base self.table_name = "memento_sessions" has_many :states, :class_name => "Memento::State", :dependent => :delete_all, :order => "id DESC" belongs_to :user attr_accessible nil 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 end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
memento-0.4.2 | lib/memento/session.rb |
memento-0.4.1 | lib/memento/session.rb |