Method: Mongo::Session#materialize_if_needed

Defined in:
lib/mongo/session.rb

#materialize_if_neededSession

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

If not already set, populate a session objects’s server_session by checking out a session from the session pool.

Returns:

  • Self.

Since:

  • 2.5.0

API:

  • private



1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
# File 'lib/mongo/session.rb', line 1146

def materialize_if_needed
  if ended?
    raise Error::SessionEnded
  end

  return unless implicit? && !@server_session

  @server_session = cluster.session_pool.checkout

  self
end