class DCell::Registry::S3Adapter::GlobalRegistry

Public Class Methods

new(bucket) click to toggle source
# File lib/dcell/registries/s3_adapter.rb, line 73
def initialize(bucket)
  @bucket = bucket
end

Public Instance Methods

clear() click to toggle source
# File lib/dcell/registries/s3_adapter.rb, line 99
def clear
  @bucket.objects.with_prefix('globals/').map(&:delete)
end
get(key) click to toggle source
# File lib/dcell/registries/s3_adapter.rb, line 77
def get(key)
  string = @bucket.objects["globals/#{key}"].read
  Marshal.load string if string
rescue AWS::S3::Errors::NoSuchKey
  Logger.error "No such global key #{key}"
  nil
end
global_keys() click to toggle source

The keys to all globals in the system

# File lib/dcell/registries/s3_adapter.rb, line 92
def global_keys
  @bucket.objects.with_prefix('globals/').inject([]) do |arr, elt|
    elt.key =~ /^globals\/(.+)$/
    arr << $1
  end
end
set(key, value) click to toggle source

Set a global value

# File lib/dcell/registries/s3_adapter.rb, line 86
def set(key, value)
  string = Marshal.dump value
  @bucket.objects["globals/#{key}"].write(string)
end