Sha256: cefda6813b5cf3a9319cccf10552e7ba100a8b70763fef02424362ed3bdc1df6

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

class ActiveRecord::Base
  class << self
    def cassandra_connection(config)
      begin
        require 'jdbc/cassandra'
        ::Jdbc::Cassandra.load_driver(:require) if defined?(::Jdbc::Cassandra.load_driver)
      rescue LoadError # assuming driver.jar is on the class-path
      end

      config[:host] ||= '127.0.0.1'
      config[:port] ||= 9160
      config[:url] ||= "jdbc:cassandra://#{config[:host]}:#{config[:port]}/#{config[:database]}"
      config[:driver] ||= defined?(::Jdbc::Cassandra.driver_name) ? ::Jdbc::Cassandra.driver_name : 'org.apache.cassandra.cql.jdbc.CassandraDriver'
      config[:adapter_class] = ActiveRecord::ConnectionAdapters::CassandraAdapter
      config[:adapter_spec] = ::ArJdbc::Cassandra

      options = (config[:options] ||= {})
      #options['zeroDateTimeBehavior'] ||= 'convertToNull'
      #options['jdbcCompliantTruncation'] ||= 'false'
      #options['useUnicode'] ||= 'true'
      #options['characterEncoding'] = config[:encoding] || 'utf8'

      jdbc_connection(config)
    end
    alias_method :jdbccassandra_connection, :cassandra_connection
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activerecord-jdbccassandra-adapter-0.0.1 lib/arjdbc/cassandra/connection_methods.rb