Sha256: d63468bbbf61186caadaf1372a00a48cc2ce04e4afc52448e6dd77772433ceea

Contents?: true

Size: 862 Bytes

Versions: 3

Compression:

Stored size: 862 Bytes

Contents

module CassandraObject
  module Consistency
    extend ActiveSupport::Concern

    included do
      cattr_accessor :consistency_levels
      self.consistency_levels = [:one, :quorum, :all]

      class_attribute :write_consistency
      class_attribute :read_consistency
      self.write_consistency  = :quorum
      self.read_consistency   = :quorum
    end

    module ClassMethods
      THRIFT_LEVELS = {
        one:    Cassandra::Consistency::ONE,
        quorum: Cassandra::Consistency::QUORUM,
        all:    Cassandra::Consistency::ALL
      }

      def thrift_read_consistency
        THRIFT_LEVELS[read_consistency] || (raise "Invalid consistency level #{read_consistency}")
      end

      def thrift_write_consistency
        THRIFT_LEVELS[write_consistency] || (raise "Invalid consistency level #{write_consistency}")
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gotime-cassandra_object-4.0.2 lib/cassandra_object/consistency.rb
gotime-cassandra_object-4.0.1 lib/cassandra_object/consistency.rb
gotime-cassandra_object-4.0.0 lib/cassandra_object/consistency.rb