composable_operations 0.10.0 → 0.10.1
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1625a77cc6ddbf6e011cb4e2a967d5ab491e8689
|
4
|
+
data.tar.gz: 5f1c9270151db8f4b52efc01366d00d12e3975b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e014a75115eb0939b2b3616138c7c8c70fea8d93bbc5d07d5e0a54d211a22ea14a69bf999bfdfb8d47009a852f130a6cafdee1de7d0a9857a2181ba60c30e790
|
7
|
+
data.tar.gz: 451f1c59b1eb0a8163d8e7a63fc4fca418ec35483d0e79fcee76063120c5cef8489e3bba398eda83ccb6b5a92164ace4b6724f71189966dea5373b921c64612d
|
@@ -4,10 +4,8 @@ module ComposableOperations
|
|
4
4
|
include SmartProperties
|
5
5
|
|
6
6
|
class << self
|
7
|
-
attr_writer :arguments
|
8
|
-
|
9
7
|
def arguments
|
10
|
-
|
8
|
+
[]
|
11
9
|
end
|
12
10
|
|
13
11
|
def arity
|
@@ -64,10 +62,8 @@ module ComposableOperations
|
|
64
62
|
when 0
|
65
63
|
raise ArgumentError, "#{self}.#{__callee__} expects at least one argument"
|
66
64
|
else
|
67
|
-
names.
|
68
|
-
|
69
|
-
arguments << name
|
70
|
-
end
|
65
|
+
names.each { |name| property(name, required: true) unless properties.key?(name) }
|
66
|
+
define_singleton_method(:arguments) { names }
|
71
67
|
end
|
72
68
|
end
|
73
69
|
|
@@ -126,5 +126,66 @@ describe ComposableOperations::Operation do
|
|
126
126
|
|
127
127
|
it { is_expected.to succeed_to_perform.when_initialized_with("-", 3).and_return("---") }
|
128
128
|
end
|
129
|
+
|
130
|
+
context "inheritance" do
|
131
|
+
let(:base_operation) do
|
132
|
+
Class.new(described_class) do
|
133
|
+
processes :text
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
let(:sub_operation) do
|
138
|
+
Class.new(base_operation) do
|
139
|
+
def execute
|
140
|
+
text.upcase
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
let(:sub_operation_with_different_input) do
|
146
|
+
Class.new(base_operation) do
|
147
|
+
processes :text, :multiplier
|
148
|
+
def execute
|
149
|
+
text * multiplier
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
context "the base operation" do
|
155
|
+
subject! { base_operation }
|
156
|
+
|
157
|
+
it "should take one argument" do
|
158
|
+
expect(base_operation.arity).to eq(1)
|
159
|
+
expect(base_operation.arguments).to eq([:text])
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
context "the sub operation" do
|
164
|
+
subject! { sub_operation }
|
165
|
+
|
166
|
+
it "should take one argument" do
|
167
|
+
expect(base_operation.arity).to eq(1)
|
168
|
+
expect(base_operation.arguments).to eq([:text])
|
169
|
+
end
|
170
|
+
|
171
|
+
it { is_expected.to succeed_to_perform.when_initialized_with("lorem ipsum").and_return("LOREM IPSUM") }
|
172
|
+
end
|
173
|
+
|
174
|
+
context "the sub operation with different input" do
|
175
|
+
subject! { sub_operation_with_different_input }
|
176
|
+
|
177
|
+
it "should take two arguments" do
|
178
|
+
expect(sub_operation_with_different_input.arity).to eq(2)
|
179
|
+
expect(sub_operation_with_different_input.arguments).to eq([:text, :multiplier])
|
180
|
+
end
|
181
|
+
|
182
|
+
it "should not influence the arguments of base operation" do
|
183
|
+
expect(base_operation.arity).to eq(1)
|
184
|
+
expect(base_operation.arguments).to eq([:text])
|
185
|
+
end
|
186
|
+
|
187
|
+
it { is_expected.to succeed_to_perform.when_initialized_with("-", 3).and_return("---") }
|
188
|
+
end
|
189
|
+
end
|
129
190
|
end
|
130
191
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: composable_operations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Konstantin Tennhard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: smart_properties
|