dm-master-slave-adapter 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -83,13 +83,12 @@ with:
83
83
  DataMapper.repository(:default).adapter.reset_binding
84
84
 
85
85
  In a web application, you'll typically want to reset the binding to master at the end
86
- of each request, to ensure subsquent requests are not permanently bound to the master.
87
-
88
- A Rack middleware is provided to do this automatically. The easiest way to use this in
89
- a Rails application, is to mount it inside your ApplicationController:
86
+ of each request, to ensure subsquent requests are not permanently bound to the master. A
87
+ Rack middleware is provided to do this automatically. The easiest way to use this in a
88
+ Rails application, is to mount it inside your ApplicationController:
90
89
 
91
90
  class ApplicationController < ActionController::Base
92
- use DataMapper::MasterSlaveAdapter::Binding, :default
91
+ use DataMapper::MasterSlaveAdapter::Middleware::WriteUnbinding, :default
93
92
  end
94
93
 
95
94
  You can use the middleware anywhere a Rack middleware can be used, however, but it must
@@ -55,6 +55,10 @@ module DataMapper
55
55
  self
56
56
  end
57
57
 
58
+ def kind_of?(kind)
59
+ super || master.kind_of?(kind)
60
+ end
61
+
58
62
  private
59
63
 
60
64
  def reader
@@ -36,6 +36,10 @@ module DataMapper
36
36
  random_adapter.send(meth, *args, &block)
37
37
  end
38
38
 
39
+ def kind_of?(kind)
40
+ super || random_adapter.kind_of?(kind)
41
+ end
42
+
39
43
  private
40
44
 
41
45
  def random_adapter
@@ -1,5 +1,5 @@
1
1
  module DataMapper
2
2
  module MasterSlaveAdapter
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -53,6 +53,17 @@ describe DataMapper::Adapters::MasterSlaveAdapter do
53
53
  end
54
54
  end
55
55
 
56
+ describe "#kind_of?" do
57
+ it "returns true if kind matches itself" do
58
+ @adapter.kind_of?(DataMapper::Adapters::MasterSlaveAdapter).should be_true
59
+ end
60
+
61
+ it "delegates to the master if kind does not match itself" do
62
+ @master.should_receive(:kind_of?).with(String).and_return(false)
63
+ @adapter.kind_of?(String).should be_false
64
+ end
65
+ end
66
+
56
67
  describe "state" do
57
68
  it "allows binding reads to the master" do
58
69
  @adapter.bind_to_master
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-master-slave-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-15 00:00:00.000000000Z
12
+ date: 2011-10-01 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &16062280 !ruby/object:Gem::Requirement
16
+ requirement: &10139680 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *16062280
24
+ version_requirements: *10139680
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: dm-core
27
- requirement: &16061600 !ruby/object:Gem::Requirement
27
+ requirement: &10138720 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *16061600
35
+ version_requirements: *10138720
36
36
  description: ! " Provides the ability to use DataMapper in an environment where\n
37
37
  \ database replication draws the need for using separate connections\n for
38
38
  reading and writing data.\n\n This adapter simply wraps two other \"real\" DataMapper