Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:brewster/cequel

* 'master' of github.com:brewster/cequel:
  support initial creation of cassandra keyspace
  allow erb yml files
  • Loading branch information...
commit cc0e2f6e8f1a5e1cb76e5064553a4cfe6c49c831 2 parents cc61b19 + c1b2a04
@outoftime outoftime authored
Showing with 21 additions and 5 deletions.
  1. +20 −4 lib/cequel/keyspace.rb
  2. +1 −1  lib/cequel/model/railtie.rb
View
24 lib/cequel/keyspace.rb
@@ -55,12 +55,17 @@ def self.slowlog_threshold
def self.connection_pool
@connection_pool ||= ConnectionPool.new(:size => 10, :timeout => 5) do
- @connection || CassandraCQL::Database.new(
+ connection
+ end
+ end
+
+ def self.connection
+ options = @keyspace ? {:keyspace => @keyspace } : {}
+ @connection || CassandraCQL::Database.new(
@hosts,
- { :keyspace => @keyspace },
+ options,
@thrift_options
)
- end
end
def self.clear_active_connections!
@@ -134,7 +139,18 @@ def batch(options = {})
set_batch(old_batch)
end
- private
+ def self.create(configuration)
+ configure(configuration.merge(:keyspace => nil))
+ connection.execute "CREATE KEYSPACE #{configuration[:keyspace]} with #{configuration[:strategy]}"
+ configure(configuration)
+ end
+
+ def self.drop(configuration)
+ configure(configuration.merge(:keyspace => nil))
+ connection.execute "DROP KEYSPACE #{configuration[:keyspace]}"
+ end
+
+ private
def get_batch
::Thread.current[batch_key]
View
2  lib/cequel/model/railtie.rb
@@ -10,7 +10,7 @@ class Railtie < Rails::Railtie
config_path = Rails.root.join('config/cequel.yml').to_s
if File.exist?(config_path)
- yaml = YAML.load_file(config_path)[Rails.env]
+ yaml = YAML::load(ERB.new(IO.read(config_path)).result)[Rails.env]
Cequel::Model.configure(yaml.symbolize_keys) if yaml
end
Please sign in to comment.
Something went wrong with that request. Please try again.