Sha256: 043d87ec70d8526b178fcfc1cfd15469aded76aafb670406300097ca7d5593fc
Contents?: true
Size: 976 Bytes
Versions: 1
Compression:
Stored size: 976 Bytes
Contents
module CassandraObject module Connection extend ActiveSupport::Concern included do class_attribute :connection_config end module ClassMethods DEFAULT_OPTIONS = { servers: "127.0.0.1:9160", thrift: {} } def establish_connection(spec) self.connection_config = spec.reverse_merge(DEFAULT_OPTIONS) end def connection @@connection ||= Cassandra.new(connection_config[:keyspace], connection_config[:servers], connection_config[:thrift].symbolize_keys!) end def cql @@cql ||= CassandraCQL::Database.new(connection_config[:servers], keyspace: connection_config[:keyspace]) end def execute_cql(cql_string, *bind_vars) statement = CassandraCQL::Statement.sanitize(cql_string, bind_vars) ActiveSupport::Notifications.instrument("cql.cassandra_object", cql: statement) do cql.execute statement end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gotime-cassandra_object-4.0.0 | lib/cassandra_object/connection.rb |