Class: Believer::Test::Database
- Inherits:
-
Object
- Object
- Believer::Test::Database
- Defined in:
- lib/believer/test/database.rb
Class Method Summary collapse
-
.setup(options = {}) ⇒ Object
Drop, and create the keyspace.
Class Method Details
.setup(options = {}) ⇒ Object
Drop, and create the keyspace. If options contains classes, creates all tables
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/believer/test/database.rb', line 9 def self.setup( = {}) env = [:environment] || Believer::Base.environment connection = env.create_connection(:connect_to_keyspace => false) keyspace = ::Believer::KeySpace.new(env) # First delete the existing keyspace begin #env.logger.debug "Dropping keyspace" keyspace.drop rescue Cql::QueryError end keyspace.create({}) connection.use(env.connection_configuration[:keyspace]) ::Believer::Base.environment = env classes = [:classes] classes.each do |cl| if cl.is_a?(String) clazz = cl.split('::').inject(Kernel) { |scope, const_name| scope.const_get(const_name) } elsif cl.is_a?(Class) clazz = cl end if clazz.ancestors.include?(Believer::Base) #puts "Creating table #{clazz.table_name}" clazz.create_table() end end unless classes.nil? || classes.empty? end |