Sets self
to compare keys using identity (rather than mere equality); returns self
:
By default, two keys are considered to be the same key if and only if they are equal objects (per method ==
):
h = {} h['x'] = 0 h['x'] = 1 # Overwrites. h # => {"x"=>1}
When this method has been called, two keys are considered to be the same key if and only if they are the same object:
h.compare_by_identity h['x'] = 2 # Does not overwrite. h # => {"x"=>1, "x"=>2}
Related: compare_by_identity?
; see also Methods for Comparing.
Returns whether compare_by_identity
has been called:
h = {} h.compare_by_identity? # => false h.compare_by_identity h.compare_by_identity? # => true
Related: compare_by_identity
; see also Methods for Comparing.
Checks for a method provided by this the delegate object by forwarding the call through _getobj_.
Handle BasicObject
instances
If the corresponding value is not set, yield a value with init_block and store the value in thread-safe manner. This method returns corresponding stored value.
(1..10).map{ Thread.new(it){|i| Ractor.store_if_absent(:s){ f(); i } #=> return stored value of key :s } }.map(&:value).uniq.size #=> 1 and f() is called only once
Attempts to enter exclusive section. Returns false
if lock fails.
For backward compatibility
Ensures that the MonitorMixin
is owned by the current thread, otherwise raises an exception.
Load multiple documents given in yaml
. Returns the parsed documents as a list.
Example:
Psych.safe_load_stream("--- foo\n...\n--- bar\n...") # => ['foo', 'bar'] list = [] Psych.safe_load_stream("--- foo\n...\n--- bar\n...") do |ruby| list << ruby end list # => ['foo', 'bar']
Register a Gem::Specification
for default gem.
Two formats for the specification are supported:
MRI 2.0 style, where spec.files contains unprefixed require names. The spec’s filenames will be registered as-is.
New style, where spec.files contains files prefixed with paths from spec.require_paths. The prefixes are stripped before registering the spec’s filenames. Unprefixed files are omitted.
Default options for gem commands for Ruby
packagers.
The options here should be structured as an array of string “gem” command names as keys and a string of the default options as values.
Example:
def self.operating_system_defaults
{ 'install' => '--no-rdoc --no-ri --env-shebang', 'update' => '--no-rdoc --no-ri --env-shebang' }
end
Sets the SSL/TLS protocol version for the context. This forces connections to use only the specified protocol version. This is deprecated and only provided for backwards compatibility. Use min_version=
and max_version=
instead.
As the name hints, this used to call the SSL_CTX_set_ssl_version() function which sets the SSL
method used for connections created from the context. As of Ruby/OpenSSL 2.1, this accessor method is implemented to call min_version=
and max_version=
instead.
Sets the lower bound on the supported SSL/TLS protocol version. The version may be specified by an integer constant named OpenSSL::SSL::*_VERSION, a Symbol
, or nil
which means “any version”.
ctx = OpenSSL::SSL::SSLContext.new ctx.min_version = OpenSSL::SSL::TLS1_1_VERSION ctx.max_version = OpenSSL::SSL::TLS1_2_VERSION sock = OpenSSL::SSL::SSLSocket.new(tcp_sock, ctx) sock.connect # Initiates a connection using either TLS 1.1 or TLS 1.2
Sets the upper bound of the supported SSL/TLS protocol version. See min_version=
for the possible values.
A non-blocking version of sysread
. Raises an SSLError
if reading would block. If “exception: false” is passed, this method returns a symbol of :wait_readable, :wait_writable, or nil, rather than raising an exception.
Reads length bytes from the SSL
connection. If a pre-allocated buffer is provided the data will be written into it.
Returns a String
representing the SSL/TLS version that was negotiated for the connection, for example “TLSv1.2”.
Returns true
if a reused session was negotiated during the handshake.
Specify whether the response shall contain the timestamp authority’s certificate or not. The default value is true
.
Indicates whether the response shall contain the timestamp authority’s certificate or not.