diff --git a/lib/mongo/connection.rb b/lib/mongo/connection.rb index c476a58..e84b7ba 100644 --- a/lib/mongo/connection.rb +++ b/lib/mongo/connection.rb @@ -470,6 +470,7 @@ module Mongo def read_primary? @read_primary end + alias :primary? :read_primary? # Close the connection to the database. def close diff --git a/lib/mongo/repl_set_connection.rb b/lib/mongo/repl_set_connection.rb index 2367be5..4f4fa00 100644 --- a/lib/mongo/repl_set_connection.rb +++ b/lib/mongo/repl_set_connection.rb @@ -137,6 +137,7 @@ module Mongo def read_primary? !@read_pool || @read_pool.length.zero? end + alias :primary? :read_primary? # Close the connection to the database. def close diff --git a/test/replica_sets/connect_test.rb b/test/replica_sets/connect_test.rb index 87ae0b2..691b556 100644 --- a/test/replica_sets/connect_test.rb +++ b/test/replica_sets/connect_test.rb @@ -32,6 +32,7 @@ class ConnectTest < Test::Unit::TestCase [RS.host, RS.ports[2]], :name => RS.name) assert @conn.connected? assert @conn.read_primary? + assert @conn.primary? assert_equal RS.primary, @conn.primary assert_equal RS.secondaries.sort, @conn.secondaries.sort diff --git a/test/replica_sets/query_secondaries.rb b/test/replica_sets/query_secondaries.rb index fe1770e..a6f1e1a 100644 --- a/test/replica_sets/query_secondaries.rb +++ b/test/replica_sets/query_secondaries.rb @@ -18,6 +18,7 @@ class ReplicaSetQuerySecondariesTest < Test::Unit::TestCase def test_read_primary assert !@conn.read_primary? + assert !@conn.primary? end def test_con