Skip to content

Commit 8f9843e

Browse files
committed
Enhanced RDoc
1 parent 8de41c1 commit 8f9843e

File tree

1 file changed

+13
-28
lines changed

1 file changed

+13
-28
lines changed

lib/pstore.rb

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
# end
106106
#
107107
# Instance methods in \PStore may be called only from within a transaction
108-
# ()exception: #path may be called from anywhere).
108+
# (exception: #path may be called from anywhere).
109109
# This assures that the call is executed only when the store is secure and stable.
110110
#
111111
# As seen above, changes in a transaction are made automatically
@@ -367,9 +367,6 @@ def in_transaction_wr
367367
end
368368
private :in_transaction, :in_transaction_wr
369369

370-
# :call-seq:
371-
# pstore[key]
372-
#
373370
# Returns the object for the given +key+ if the key exists.
374371
# +nil+ otherwise;
375372
# if not +nil+, the returned value is an object or a hierarchy of objects:
@@ -384,14 +381,11 @@ def in_transaction_wr
384381
# See also {Deep Root Values}[rdoc-ref:PStore@Deep+Root+Values].
385382
#
386383
# Raises an exception if called outside a transaction block.
387-
def [](name)
384+
def [](key)
388385
in_transaction
389-
@table[name]
386+
@table[key]
390387
end
391388

392-
# :call-seq:
393-
# fetch(key)
394-
#
395389
# Like #[], except that it accepts a default value for the store.
396390
# If the root for the given +key+ does not exist:
397391
#
@@ -404,21 +398,18 @@ def [](name)
404398
# end
405399
#
406400
# Raises an exception if called outside a transaction block.
407-
def fetch(name, default=PStore::Error)
401+
def fetch(key, default=PStore::Error)
408402
in_transaction
409-
unless @table.key? name
403+
unless @table.key? key
410404
if default == PStore::Error
411-
raise PStore::Error, format("undefined root name `%s'", name)
405+
raise PStore::Error, format("undefined root key `%s'", key)
412406
else
413407
return default
414408
end
415409
end
416-
@table[name]
410+
@table[key]
417411
end
418412

419-
# :call-seq:
420-
# pstore[key] = value
421-
#
422413
# Creates or replaces an object or hierarchy of objects
423414
# at the root for +key+:
424415
#
@@ -430,14 +421,11 @@ def fetch(name, default=PStore::Error)
430421
# See also {Deep Root Values}[rdoc-ref:PStore@Deep+Root+Values].
431422
#
432423
# Raises an exception if called outside a transaction block.
433-
def []=(name, value)
424+
def []=(key, value)
434425
in_transaction_wr
435-
@table[name] = value
426+
@table[key] = value
436427
end
437428

438-
# :call-seq:
439-
# delete(key)
440-
#
441429
# Removes and returns the value at +key+ if it exists:
442430
#
443431
# store = PStore.new('t.store')
@@ -449,9 +437,9 @@ def []=(name, value)
449437
# Returns +nil+ if there is no such root.
450438
#
451439
# Raises an exception if called outside a transaction block.
452-
def delete(name)
440+
def delete(key)
453441
in_transaction_wr
454-
@table.delete name
442+
@table.delete key
455443
end
456444

457445
# Returns an array of the keys of the existing roots:
@@ -466,19 +454,16 @@ def roots
466454
@table.keys
467455
end
468456

469-
# :call-seq:
470-
# root?(key)
471-
#
472457
# Returns +true+ if there is a root for +key+, +false+ otherwise:
473458
#
474459
# store.transaction do
475460
# store.root?(:foo) # => true
476461
# end
477462
#
478463
# Raises an exception if called outside a transaction block.
479-
def root?(name)
464+
def root?(key)
480465
in_transaction
481-
@table.key? name
466+
@table.key? key
482467
end
483468

484469
# Returns the string file path used to create the store:

0 commit comments

Comments
 (0)