interactor 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/interactor.gemspec +1 -1
- data/lib/interactor.rb +1 -1
- data/spec/support/lint.rb +19 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3738599fd10bf883b7ccdc29ff2fbe4322a75851
|
4
|
+
data.tar.gz: 71e339e19b1dbcb3c4a874060ae4f38e1cd37702
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8c053d53c21e3ee48e905959e8ff8298b3caa93c7df9ad2c60793b3108cf0b1b3dd106563bd5630898bb54944b7bc6eb9b1b63dc88ee736eebdfe060265581d
|
7
|
+
data.tar.gz: b0c7b00554345b259ffbcaae25c1817f99e7796300a1c11e8f1f1939eb9e9cd20693b57667c247b74a7105fa5fadb9490adcace3d7527b8b869f61d94b222c04
|
data/README.md
CHANGED
@@ -121,7 +121,7 @@ class PlaceOrder
|
|
121
121
|
end
|
122
122
|
```
|
123
123
|
|
124
|
-
Breaking your interactors into bite-sized pieces also gives you the benefit
|
124
|
+
Breaking your interactors into bite-sized pieces also gives you the benefit of reusability. In our example above, there may be several scenarios where you may want to check inventory. Encapsulating that logic in one interactor enables you to reuse that interactor, reducing duplication.
|
125
125
|
|
126
126
|
## Examples
|
127
127
|
|
data/interactor.gemspec
CHANGED
data/lib/interactor.rb
CHANGED
data/spec/support/lint.rb
CHANGED
@@ -127,18 +127,28 @@ shared_examples :lint do
|
|
127
127
|
end
|
128
128
|
|
129
129
|
describe "context deferral" do
|
130
|
-
|
130
|
+
context "initialized" do
|
131
|
+
let(:instance) { interactor.new(foo: "bar") }
|
131
132
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
133
|
+
it "defers to keys that exist in the context" do
|
134
|
+
expect(instance).to respond_to(:foo)
|
135
|
+
expect(instance.foo).to eq("bar")
|
136
|
+
expect { instance.method(:foo) }.not_to raise_error
|
137
|
+
end
|
138
|
+
|
139
|
+
it "bombs if the key does not exist in the context" do
|
140
|
+
expect(instance).not_to respond_to(:baz)
|
141
|
+
expect { instance.baz }.to raise_error(NoMethodError)
|
142
|
+
expect { instance.method(:baz) }.to raise_error(NameError)
|
143
|
+
end
|
136
144
|
end
|
137
145
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
146
|
+
context "allocated" do
|
147
|
+
let(:instance) { interactor.allocate }
|
148
|
+
|
149
|
+
it "doesn't respond to context keys before the context is set" do
|
150
|
+
expect(instance).not_to respond_to(:foo)
|
151
|
+
end
|
142
152
|
end
|
143
153
|
end
|
144
154
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: interactor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Collective Idea
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|