Module: MyStuff::MultiDB::Unsharded

Defined in:
lib/my_stuff/multidb/unsharded.rb

Overview

Mixin for databases with no sharding (eg ServiceLocator, which defines the sharding).

See MyStuff::MultiDB for an example.

Including this defines with_master and with_slave.

Class Method Summary collapse

Class Method Details

.included(othermod) ⇒ Object

:nodoc:



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/my_stuff/multidb/unsharded.rb', line 13

def self.included othermod # :nodoc:
  othermod.send :include, MyStuff::MultiDB

  class <<othermod
    def with_master &block
      MyStuff::MultiDB.with_spec(
        self,
        self.spec_for_master,
        &block
      )
    end

    def with_slave &block
      MyStuff::MultiDB.with_spec(
        self,
        self.spec_for_slave,
        &block
      )
    end

    def spec_for_master; raise NotImplementedError.new; end
    def spec_for_slave; raise NotImplementedError.new; end
  end
end