Sha256: 4efb69273eb3d3b7582f5931a2859a385cdc2ca018b3c9622050a2e1d5f6524b

Contents?: true

Size: 1.11 KB

Versions: 4

Compression:

Stored size: 1.11 KB

Contents

module Mongoid
  module Shell
    module Properties
      module Host
        attr_accessor :host

        # database host
        if ::Mongoid::Compatibility::Version.mongoid3?
          def host
            @host || begin
              node = session.cluster.nodes.first
              fail Mongoid::Shell::Errors::SessionNotConnectedError unless node
              node.address == 'localhost:27017' ? nil : node.address
            end
          end
        elsif ::Mongoid::Compatibility::Version.mongoid4?
          def host
            @host || begin
              node = session.cluster.nodes.first
              fail Mongoid::Shell::Errors::SessionNotConnectedError unless node
              node.address.original == 'localhost:27017' ? nil : node.address.original
            end
          end
        else
          def host
            @host || begin
              node = session.cluster.servers.first
              fail Mongoid::Shell::Errors::SessionNotConnectedError unless node
              node.address.to_s == 'localhost:27017' ? nil : node.address.to_s
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mongoid-shell-0.4.3 lib/mongoid/shell/properties/host.rb
mongoid-shell-0.4.2 lib/mongoid/shell/properties/host.rb
mongoid-shell-0.4.1 lib/mongoid/shell/properties/host.rb
mongoid-shell-0.4.0 lib/mongoid/shell/properties/host.rb