End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
PStore#fetch
fetch(name, default=PStore::Error)
lib/pstore.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.0.5/lib/pstore.rb, line 171
def fetch(name, default=PStore::Error)
in_transaction
unless @table.key? name
if default == PStore::Error
raise PStore::Error, format("undefined root name `%s'", name)
else
return default
end
end
@table[name]
end
This method is just like PStore#[], save that you may also provide a default value for the object. In the event the specified name is not found in the data store, your default will be returned instead. If you do not specify a default, PStore::Error will be raised if the object is not found.
WARNING: This method is only valid in a PStore#transaction. It will raise PStore::Error if called at any other time.
See also
#empty_marshal_data
#in_transaction
#empty_marshal_checksum
#in_transaction_wr
also in
3.4 · 3.3 · 3.2 · 3.1