instance method
YAML::DBM#fetch
ydbm.fetch( key, ifnone = nil )
ydbm.fetch( key ) { |key| ... }
lib/yaml/dbm.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/yaml/dbm.rb, line 59
def fetch( keystr, ifnone = nil )
begin
val = super( keystr )
if String === val
if YAML.respond_to?(:safe_load)
return YAML.safe_load( val )
else
return YAML.load( val )
end
end
rescue IndexError
end
if block_given?
yield keystr
else
ifnone
end
end
Return value associated with key.
If there is no value for key and no block is given, returns ifnone.
Otherwise, calls block passing in the given key.
See ::DBM#fetch for more information.