Method: Persist.fetch
- Defined in:
- lib/persist/persist.rb
.fetch(table, default = nil) ⇒ Object
Public: Fetch a particular table from the persistent store.
table - A Symbol corresponding to a root table key in the persistent
store.
default - An optional value that is returned if the table is not found.
Examples
Persist.fetch :author
# => {:first_name => "Shannon", :last_name => "Skipper"}
Persist.fetch :snowman
# => nil
Persist.fetch :snowman, 'default value instead of nil'
# => "default value instead of nil"
Returns the value stored in the fetched table.
144 145 146 147 148 149 150 |
# File 'lib/persist/persist.rb', line 144 def fetch table, default = nil initialize_db @db.transaction true do @db.fetch table, default end end |