Class: Riak::Shim::Store

Inherits:
Object
  • Object
show all
Defined in:
lib/riak-shim/store.rb

Overview

Represents a connection to a particular Riak cluster

Defined Under Namespace

Classes: ConnectionError, NoSettingsForCurrentEnvError, RackEnvNotSetError

Constant Summary collapse

DEFAULT_CONFIG_LOCATION =
'config/database.yml'

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#config_locationString

The path to our configuration file. Defaults to DEFAULT_CONFIG_LOCATION

Returns:

  • (String)

    the current value of config_location



10
11
12
# File 'lib/riak-shim/store.rb', line 10

def config_location
  @config_location
end

#riakRiak::Client

The underlying Riak connection

Returns:

  • (Riak::Client)

    the current value of riak



10
11
12
# File 'lib/riak-shim/store.rb', line 10

def riak
  @riak
end

Instance Method Details

#bucket(name) ⇒ Riak::Bucket

Returns the bucket coresponding to name.

Returns:

  • (Riak::Bucket)

    the bucket coresponding to name



63
64
65
# File 'lib/riak-shim/store.rb', line 63

def bucket(name)
  riak.bucket(name)
end

#bucket_prefixString

Returns the prefix we will add to the bucket name for each class.

Returns:

  • (String)

    the prefix we will add to the bucket name for each class



45
46
47
# File 'lib/riak-shim/store.rb', line 45

def bucket_prefix
  return config['bucket_prefix']
end

#configHash

Returns the configuration for our current environment.

Returns:

  • (Hash)

    the configuration for our current environment



28
29
30
31
32
33
# File 'lib/riak-shim/store.rb', line 28

def config
  env = ENV['RACK_ENV'] or raise RackEnvNotSetError.new
  @config ||= read_config[env]
  @config or raise NoSettingsForCurrentEnvError.new(
      "RACK_ENV #{ENV['RACK_ENV']} not specified in #{config_location}.")
end

#read_configHash

Returns the entire config, ie the configuration for each environment.

Returns:

  • (Hash)

    the entire config, ie the configuration for each environment



36
37
38
# File 'lib/riak-shim/store.rb', line 36

def read_config
  YAML.load_file(config_location)
end