Sha256: 4f75b495a541baf574df374222294e9cff165410b0f2482cfc7d66cd94ceffe4

Contents?: true

Size: 545 Bytes

Versions: 1

Compression:

Stored size: 545 Bytes

Contents

module Mongoid
  module Shell
    module Properties
      module Primary

        attr_accessor :primary

        # primary database host
        def primary
          @primary || begin
            raise Mongoid::Shell::Errors::SessionNotConnectedError unless session.cluster.nodes.any?
            node = session.cluster.nodes.find(&:primary?)
            raise Mongoid::Shell::Errors::MissingPrimaryNodeError unless node
            node.address == "localhost:27017" ? nil : node.address
          end
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongoid-shell-0.2.0 lib/mongoid/shell/properties/primary.rb