switch_point 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: caaba1e17cb79206eb52931dadba051e12aa10a4
4
- data.tar.gz: a5ad7388ad8989ddd5c6a9ad9dd3a33474d4b6a3
3
+ metadata.gz: 80333b18b169594e3d1439b08df9cff562f85eff
4
+ data.tar.gz: 9d701fc245dc24a8f1736d4d0adad9bf920de04b
5
5
  SHA512:
6
- metadata.gz: 18ccaf6142ea40e8e9974cf7fb85f7b8d0bf8fe0737128f5745b66c896b39a8af5d32e5c3b238a5c1a0486a09686f5d69aa409f774f74c394182dc0e330d075d
7
- data.tar.gz: 3d4eb2f58f0e548348250567bae0e01cc873f3a4a703dd9727565cadeaad83fad295cb016e0f4d5fddd2d8fe26cec1b42de84f6d75e4f4faaf974d2280244a77
6
+ metadata.gz: d4ab8f26f462b8bdb96c97c7f39e3bd20befc4c0d94445b7c9bf3f349c06d0218bc6b314ed2ecd6435c5055cff9aaaced2d2e688a7a8d7a6c5299baf1533cb82
7
+ data.tar.gz: 5eaf795923f263f0caa615baec1f6687e8c834c80842925cb4a50fca10eb568977dc795d9704edefe7da145f5c8712ad53cb3ec4398e9eee4728025058464c38
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.2.2 (2014-05-30)
2
+ - Fix nil error on with_{readonly,writable} from non-switch_point model
3
+
1
4
  ## 0.2.1 (2014-05-29)
2
5
  - Add Proxy#switch_name to switch proxy configuration
3
6
  - Fix weird nil error when Config#define_switch_point isn't called yet
@@ -19,11 +19,19 @@ module SwitchPoint
19
19
  end
20
20
 
21
21
  def with_readonly(&block)
22
- switch_point_proxy.with_readonly(&block)
22
+ if switch_point_proxy
23
+ switch_point_proxy.with_readonly(&block)
24
+ else
25
+ block.call
26
+ end
23
27
  end
24
28
 
25
29
  def with_writable(&block)
26
- switch_point_proxy.with_writable(&block)
30
+ if switch_point_proxy
31
+ switch_point_proxy.with_writable(&block)
32
+ else
33
+ block.call
34
+ end
27
35
  end
28
36
 
29
37
  def use_switch_point(name)
@@ -32,7 +40,11 @@ module SwitchPoint
32
40
  end
33
41
 
34
42
  def switch_point_proxy
35
- ProxyRepository.checkout(@switch_point_name)
43
+ if @switch_point_name
44
+ ProxyRepository.checkout(@switch_point_name)
45
+ else
46
+ nil
47
+ end
36
48
  end
37
49
 
38
50
  private
@@ -1,3 +1,3 @@
1
1
  module SwitchPoint
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -122,6 +122,12 @@ RSpec.describe SwitchPoint::Model do
122
122
  end
123
123
  end
124
124
  end
125
+
126
+ context 'without use_switch_point' do
127
+ it 'bypasses given block' do
128
+ expect(Note.with_writable { :bypass }).to eq(:bypass)
129
+ end
130
+ end
125
131
  end
126
132
 
127
133
  describe '.with_readonly' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: switch_point
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kohei Suzuki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-29 00:00:00.000000000 Z
11
+ date: 2014-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: appraisal