Last active
December 13, 2015 21:18
-
-
Save brainopia/4975839 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Gem::Specification.new do |s| | |
s.name = 'cassandra-schema_dsl' | |
s.version = '0.1' | |
s.author = 'brainopia' | |
s.summary = 'Cassandra schema dsl' | |
s.files = ['cassandra-schema_dsl.rb'] | |
s.require_path = '.' | |
s.add_dependency 'cassandra' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Cassandra::SchemaDSL | |
def add_keyspace(options) | |
system.add_keyspace keyspace_definition options | |
end | |
def add_table(options) | |
keyspace(options[:keyspace]).add_column_family table_definition options | |
end | |
def drop_keyspace(name) | |
system.drop_keyspace name | |
end | |
private | |
def keyspace_definition(options) | |
Cassandra::Keyspace.new options.merge(cf_defs: []) | |
end | |
def table_definition(options) | |
Cassandra::ColumnFamily.new options | |
end | |
def system | |
keyspace 'system' | |
end | |
def keyspace(name) | |
Cassandra.new name | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment