Permalink
Browse files

make client stuff protected

  • Loading branch information...
1 parent 48c928a commit fc67c8a21bb6568ef5cb40b9946102f3f31b4c3f @ryanking ryanking committed Mar 3, 2010
Showing with 15 additions and 15 deletions.
  1. +15 −15 lib/cassandra/cassandra.rb
View
@@ -69,21 +69,6 @@ def initialize(keyspace, servers = "127.0.0.1:9160", thrift_client_options = {})
@servers = Array(servers)
end
- def client
- return @client if defined?(@client)
- client!
- end
-
- def client!
- @client = raw_client
- unless (keyspaces = client.get_string_list_property("keyspaces")).include?(@keyspace)
- raise AccessError, "Keyspace #{@keyspace.inspect} not found. Available: #{keyspaces.inspect}"
- end
- @servers = all_nodes
- @client.disconnect!
- @client = raw_client
- end
-
def keyspaces
@keyspaces ||= client.get_string_list_property("keyspaces")
end
@@ -273,6 +258,21 @@ def schema(load=true)
end
end
+ def client
+ @client ||= client!
+ end
+
+ def client!
+ @client = raw_client
+ unless (keyspaces = client.get_string_list_property("keyspaces")).include?(@keyspace)
+ raise AccessError, "Keyspace #{@keyspace.inspect} not found. Available: #{keyspaces.inspect}"
+ end
+ @servers = all_nodes
+ @client.disconnect!
+ @client = raw_client
+ end
+
+
def raw_client
ThriftClient.new(CassandraThrift::Cassandra::Client, @servers, @thrift_client_options)
end

0 comments on commit fc67c8a

Please sign in to comment.