class RIMS::KeyValueStore::FactoryBuilder

Attributes

factory[R]

Public Class Methods

add_plug_in(name, klass) click to toggle source
# File lib/rims/kvs.rb, line 62
def add_plug_in(name, klass)
  PLUG_IN[name] = klass
  self
end
get_plug_in(name) click to toggle source
# File lib/rims/kvs.rb, line 67
def get_plug_in(name)
  PLUG_IN[name] or raise KeyError, "not found a key-value store plug-in: #{name}"
end
new() click to toggle source
# File lib/rims/kvs.rb, line 76
def initialize
  @open = nil
  @factory = proc{|name|
    @open.call(name)
  }
end
plug_in_names() click to toggle source
# File lib/rims/kvs.rb, line 71
def plug_in_names
  PLUG_IN.keys
end

Public Instance Methods

open() { |name| ... } click to toggle source
# File lib/rims/kvs.rb, line 85
def open(&block)      # :yields: name
  @open = block
  self
end
use(middleware, *args, &block) click to toggle source
# File lib/rims/kvs.rb, line 90
def use(middleware, *args, &block)
  prev_factory = @factory
  @factory = proc{|name|
    middleware.new(prev_factory.call(name), *args, &block)
  }
  self
end