Parent

Included Modules

Class/Module Index [+]

Quicksearch

Ruote::CompositeStorage

This storage allows for mixing of storage implementation or simply mixing of storage physical backend.

opts = {}

engine =
  Ruote::Engine.new(
    Ruote::Worker.new(
      Ruote::CompositeStorage.new(
        Ruote::FsStorage.new('ruote_work', opts),
        'msgs' => Ruote::HashStorage.new(opts))))

In this example, everything goes to the FsStorage, except the messages (msgs) that go to an in-memory storage.

Constants

STORAGE_BASE_METHODS

def add_type (type) end

TYPES

Public Class Methods

new(default_storage, storages) click to toggle source
# File lib/ruote/storage/composite_storage.rb, line 50
def initialize (default_storage, storages)

  @default_storage = default_storage
  @storages = storages

  prepare_base_methods
end

Public Instance Methods

delete(doc) click to toggle source
# File lib/ruote/storage/composite_storage.rb, line 68
def delete (doc)

  storage(type).delete(doc)
end
get(type, key) click to toggle source
# File lib/ruote/storage/composite_storage.rb, line 63
def get (type, key)

  storage(type).get(type, key)
end
get_many(type, key=nil, opts={}) click to toggle source
# File lib/ruote/storage/composite_storage.rb, line 73
def get_many (type, key=nil, opts={})

  storage(type).get_many(type, key, opts)
end
ids(type) click to toggle source
# File lib/ruote/storage/composite_storage.rb, line 78
def ids (type)

  storage(type).ids(type)
end
purge!() click to toggle source
# File lib/ruote/storage/composite_storage.rb, line 83
def purge!

  TYPES.collect { |t| storage(t) }.uniq.each { |s| s.purge! }
end
purge_type!(type) click to toggle source
# File lib/ruote/storage/composite_storage.rb, line 88
def purge_type! (type)

  storage(type).purge_type!(type)
end
put(doc, opts={}) click to toggle source
# File lib/ruote/storage/composite_storage.rb, line 58
def put (doc, opts={})

  storage(doc['type']).put(doc, opts)
end

Protected Instance Methods

prepare_base_methods() click to toggle source
# File lib/ruote/storage/composite_storage.rb, line 116
def prepare_base_methods

  singleton = class << self; self; end

  STORAGE_BASE_METHODS.each do |method, type|

    singleton.send(:define_method, method) do |*args|
      storage(type).send(method, *args)
    end
  end
end
storage(type) click to toggle source
# File lib/ruote/storage/composite_storage.rb, line 128
def storage (type)

  @storages[type] || @default_storage
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.