ruby-changes:72396
From: BurdetteLamar <ko1@a...>
Date: Sat, 2 Jul 2022 21:49:29 +0900 (JST)
Subject: [ruby-changes:72396] 2dafa0470b (master): [ruby/pstore] Enhanced RDoc
https://git.ruby-lang.org/ruby.git/commit/?id=2dafa0470b From 2dafa0470b29abd91a2f057819c8baa4a7601de2 Mon Sep 17 00:00:00 2001 From: BurdetteLamar <BurdetteLamar@Y...> Date: Wed, 29 Jun 2022 11:07:50 -0500 Subject: [ruby/pstore] Enhanced RDoc https://github.com/ruby/pstore/commit/8f9843ef19 --- lib/pstore.rb | 41 +++++++++++++---------------------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/lib/pstore.rb b/lib/pstore.rb index b4e06ce2d6..f029b87513 100644 --- a/lib/pstore.rb +++ b/lib/pstore.rb @@ -105,7 +105,7 @@ require "digest" https://github.com/ruby/ruby/blob/trunk/lib/pstore.rb#L105 # end # # Instance methods in \PStore may be called only from within a transaction -# ()exception: #path may be called from anywhere). +# (exception: #path may be called from anywhere). # This assures that the call is executed only when the store is secure and stable. # # As seen above, changes in a transaction are made automatically @@ -367,9 +367,6 @@ class PStore https://github.com/ruby/ruby/blob/trunk/lib/pstore.rb#L367 end private :in_transaction, :in_transaction_wr - # :call-seq: - # pstore[key] - # # Returns the object for the given +key+ if the key exists. # +nil+ otherwise; # if not +nil+, the returned value is an object or a hierarchy of objects: @@ -384,14 +381,11 @@ class PStore https://github.com/ruby/ruby/blob/trunk/lib/pstore.rb#L381 # See also {Deep Root Values}[rdoc-ref:PStore@Deep+Root+Values]. # # Raises an exception if called outside a transaction block. - def [](name) + def [](key) in_transaction - @table[name] + @table[key] end - # :call-seq: - # fetch(key) - # # Like #[], except that it accepts a default value for the store. # If the root for the given +key+ does not exist: # @@ -404,21 +398,18 @@ class PStore https://github.com/ruby/ruby/blob/trunk/lib/pstore.rb#L398 # end # # Raises an exception if called outside a transaction block. - def fetch(name, default=PStore::Error) + def fetch(key, default=PStore::Error) in_transaction - unless @table.key? name + unless @table.key? key if default == PStore::Error - raise PStore::Error, format("undefined root name `%s'", name) + raise PStore::Error, format("undefined root key `%s'", key) else return default end end - @table[name] + @table[key] end - # :call-seq: - # pstore[key] = value - # # Creates or replaces an object or hierarchy of objects # at the root for +key+: # @@ -430,14 +421,11 @@ class PStore https://github.com/ruby/ruby/blob/trunk/lib/pstore.rb#L421 # See also {Deep Root Values}[rdoc-ref:PStore@Deep+Root+Values]. # # Raises an exception if called outside a transaction block. - def []=(name, value) + def []=(key, value) in_transaction_wr - @table[name] = value + @table[key] = value end - # :call-seq: - # delete(key) - # # Removes and returns the value at +key+ if it exists: # # store = PStore.new('t.store') @@ -449,9 +437,9 @@ class PStore https://github.com/ruby/ruby/blob/trunk/lib/pstore.rb#L437 # Returns +nil+ if there is no such root. # # Raises an exception if called outside a transaction block. - def delete(name) + def delete(key) in_transaction_wr - @table.delete name + @table.delete key end # Returns an array of the keys of the existing roots: @@ -466,9 +454,6 @@ class PStore https://github.com/ruby/ruby/blob/trunk/lib/pstore.rb#L454 @table.keys end - # :call-seq: - # root?(key) - # # Returns +true+ if there is a root for +key+, +false+ otherwise: # # store.transaction do @@ -476,9 +461,9 @@ class PStore https://github.com/ruby/ruby/blob/trunk/lib/pstore.rb#L461 # end # # Raises an exception if called outside a transaction block. - def root?(name) + def root?(key) in_transaction - @table.key? name + @table.key? key end # Returns the string file path used to create the store: -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/