Skip to content

End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

PStore#abort

abort

Ends the current PStore#transaction, discarding any changes to the data store.

Example:

Example
require "pstore"

store = PStore.new("data_file.pstore")
store.transaction do  # begin transaction
  store[:one] = 1     # this change is not applied, see below...
  store[:two] = 2     # this change is not applied, see below...

  store.abort         # end transaction here, discard all changes

  store[:three] = 3   # this change is never reached
end

WARNING: This method is only valid in a PStore#transaction. It will raise PStore::Error if called at any other time.

See also #[]= #commit #[] #delete also in 3.4 · 3.3 · 3.2 · 3.0