the_help 3.1.0 → 3.2.0
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/the_help/service.rb +31 -7
- data/lib/the_help/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42d6ef0b180ed2f150956e8c1bac70fde46e1f6ef221e797e79dbefc0fbb39d7
|
4
|
+
data.tar.gz: 8656a86feb9ed3054f3a48ba59441e104cfe2db9969443dfe25e1ee568946e19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d044c6844fc1a052afc36f05f255384eb6234b86b2de566a71779f48c2f5769cae6802c329a2cc3f238b3e6587b868056e5b96cb05c9d2cecc51b41a77e913ab
|
7
|
+
data.tar.gz: 7ee92bcb59848b90883e5e62d0899c2dcca9b881e7898a186ef629c841923386191d541a2850ed4a0a05bfcb2c4f87bdfd8df1c12f9cdb24bb2dd57e41739326
|
data/Gemfile.lock
CHANGED
data/lib/the_help/service.rb
CHANGED
@@ -150,18 +150,42 @@ module TheHelp
|
|
150
150
|
self
|
151
151
|
end
|
152
152
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
153
|
+
# Defines a service input
|
154
|
+
#
|
155
|
+
# The specified input becomes a named parameter for the service's `#call` method.
|
156
|
+
#
|
157
|
+
# @param name [Symbol] This becomes the name of the input parameter
|
158
|
+
#
|
159
|
+
# @param block [Proc] If a block is provided, the contents of the block will be executed in
|
160
|
+
# the scope of the service instance in order to provide the default
|
161
|
+
# value of the input. This is different than providing a Proc to the
|
162
|
+
# `:default` option, which would simply return the Proc itself as the
|
163
|
+
# default value rather than calling it.
|
164
|
+
#
|
165
|
+
# @option options [Object] :default If specified (and no block is given), this becomes the
|
166
|
+
# literal default value for the input.
|
167
|
+
def input(name, **options, &block)
|
168
|
+
if options.key?(:default) || block
|
169
|
+
make_optional_input(name, options[:default], &block)
|
160
170
|
else
|
171
|
+
attr_accessor name, make_private: true
|
161
172
|
required_inputs << name
|
162
173
|
end
|
163
174
|
self
|
164
175
|
end
|
176
|
+
|
177
|
+
private
|
178
|
+
|
179
|
+
def make_optional_input(name, default, &block)
|
180
|
+
attr_writer name
|
181
|
+
private "#{name}="
|
182
|
+
default_routine = block || -> { default }
|
183
|
+
define_method("_#{name}", &default_routine)
|
184
|
+
define_method(name) do
|
185
|
+
instance_variable_get("@#{name}") || send("_#{name}")
|
186
|
+
end
|
187
|
+
required_inputs.delete(name)
|
188
|
+
end
|
165
189
|
end
|
166
190
|
|
167
191
|
# Holds the result of running a service as well as the execution status
|
data/lib/the_help/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: the_help
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Wilger
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|