Class: Riak::Shim::Store
- Inherits:
-
Object
- Object
- Riak::Shim::Store
- 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
-
#config_location ⇒ String
The path to our configuration file.
-
#riak ⇒ Riak::Client
The underlying Riak connection.
Instance Method Summary collapse
-
#bucket(name) ⇒ Riak::Bucket
The bucket coresponding to name.
-
#bucket_prefix ⇒ String
The prefix we will add to the bucket name for each class.
-
#config ⇒ Hash
The configuration for our current environment.
-
#read_config ⇒ Hash
The entire config, ie the configuration for each environment.
Instance Attribute Details
#config_location ⇒ String
The path to our configuration file. Defaults to DEFAULT_CONFIG_LOCATION
10 11 12 |
# File 'lib/riak-shim/store.rb', line 10 def config_location @config_location end |
#riak ⇒ Riak::Client
The underlying Riak connection
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.
63 64 65 |
# File 'lib/riak-shim/store.rb', line 63 def bucket(name) riak.bucket(name) end |
#bucket_prefix ⇒ String
Returns 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 |
#config ⇒ Hash
Returns 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_config ⇒ Hash
Returns 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 |