module Cassie::Configuration::Core

Extend a class with Core to add configuration management methods and attributes

Attributes

keyspace[RW]

The currently selected keyspace. If no keyspace has been explicitly set, then the default :keyspace from {#configuration} is used.

Public Class Methods

extended(extender) click to toggle source

@!visibility private

# File lib/cassie/configuration/core.rb, line 15
def self.extended(extender)
  extender.paths["cluster_configurations"] = "config/cassandra.yml"
end

Public Instance Methods

configuration() click to toggle source

The currently active configuration used for initializing new cluster connections. If none has been set, the configuration for the current {#env} is used from {#configuration}

Note: setting a {#configuration} value will override the {#configurations} attribute, rendering it useless @return [Hash{String,Symbol => Object}] Hash of cassandra-driver supported cluster configuration attributes @!parse attr_accessor :configuration

# File lib/cassie/configuration/core.rb, line 61
def configuration
  return @configuration if defined?(@configuration)
  configurations[env]
end
configuration=(val) click to toggle source
# File lib/cassie/configuration/core.rb, line 66
def configuration=(val)
  @configuration = val
end
configurations() click to toggle source

The cluster configurations available for all environments @return [Hash{String => [Hash]}] Cluster configurations, keyed by environment. @!parse attr_accessor :configurations

# File lib/cassie/configuration/core.rb, line 41
def configurations
  @configurations ||= cluster_configurations
end
configurations=(val) click to toggle source
# File lib/cassie/configuration/core.rb, line 45
def configurations=(val)
  if val && defined?(@configuration)
    puts "WARNING: Setting `configurations` will have no effect on what config is used right now. `#{self}.configuration` has previously been set explicitly and will be used instead."
  end
  @configurations = val
end
env() click to toggle source

The currently active environment. Used to select which configuration will be used @!parse attr_accessor :env

# File lib/cassie/configuration/core.rb, line 22
def env
  @env ||= ActiveSupport::StringInquirer.new(ENV["CASSANDRA_ENV"] || ENV["RACK_ENV"] || "development")
end
env=(val) click to toggle source
# File lib/cassie/configuration/core.rb, line 26
def env=(val)
  @env = ActiveSupport::StringInquirer.new(val)
end
paths() click to toggle source

Paths used for configuration loading.

@return [Hash]

* +:cluster_configurations+ - The .yml file defining the configuration for your cluster for various environments.
# File lib/cassie/configuration/core.rb, line 34
def paths
  @paths ||= {}.with_indifferent_access
end