Sha256: e6dce694913a45f97c4692623431e7407da80b6995b2f91b50e25f7e04ca6049
Contents?: true
Size: 1.19 KB
Versions: 4
Compression:
Stored size: 1.19 KB
Contents
module Mongoid module Shell module Properties module Username attr_accessor :username # current username if ::Mongoid::Compatibility::Version.mongoid3? def username @username || begin return nil unless session.context.cluster.auth && session.context.cluster.auth.first session.context.cluster.auth.first[1][0] end end elsif ::Mongoid::Compatibility::Version.mongoid4? def username @username || begin node = session.cluster.nodes.first fail Mongoid::Shell::Errors::SessionNotConnectedError unless node return nil if !node.credentials.key?(db) || node.credentials[db].empty? node.credentials[db][0] end end else def username @username || begin server = session.cluster.servers.first fail Mongoid::Shell::Errors::SessionNotConnectedError unless server server.context.with_connection do |connection| connection.options[:user] end end end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems