service_pattern 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/service_pattern/service.rb +34 -0
- data/lib/service_pattern/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7ec1a1bdbbf5c1579ff34c0acdf54220b88ce43e845a4dcbc99ab930f8a6f49
|
4
|
+
data.tar.gz: fb09e4e6237d5eb07f028fab2968bbe178775b4b1fdae3d34a23550139b2c7cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8410e3bbde7f41d0f66ac4d7e4acc347901259ae4bd4817cdf66f1b872380915b3579359579ce2c137e14436d0d96e0b65360569003488ea4a9455b76513e447
|
7
|
+
data.tar.gz: 9802cae2a1eca34b23962af137890f226dfb274d2bd219d5aaf8d23fd6c9225423406525acd7720c94e6332a4ca101dfc75257781a6399db310865a95ee1e1df
|
@@ -39,6 +39,40 @@ class ServicePattern::Service
|
|
39
39
|
raise error
|
40
40
|
end
|
41
41
|
|
42
|
+
def self.arguments(*arguments)
|
43
|
+
arguments.each do |argument_name|
|
44
|
+
argument argument_name
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.argument(argument_name, **args)
|
49
|
+
attr_accessor argument_name
|
50
|
+
|
51
|
+
@arguments ||= {}
|
52
|
+
@arguments[argument_name] ||= {}
|
53
|
+
|
54
|
+
args.each do |key, value|
|
55
|
+
if key == :default
|
56
|
+
@arguments[argument_name][key] = value
|
57
|
+
else
|
58
|
+
raise ArgumentError, "Invalid argument: #{argument_name}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def initialize(**args)
|
64
|
+
arguments = self.class.instance_variable_get(:@arguments)
|
65
|
+
arguments&.each do |argument_name, argument_options|
|
66
|
+
raise ArgumentError, "missing keyword: #{argument_name}" if !args.key?(argument_name) && !argument_options.key?(:default)
|
67
|
+
end
|
68
|
+
|
69
|
+
args.each do |key, value|
|
70
|
+
raise ArgumentError, "unknown keyword: #{key}" unless arguments&.key?(key)
|
71
|
+
|
72
|
+
__send__("#{key}=", value)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
42
76
|
def can_execute?
|
43
77
|
succeed!
|
44
78
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: service_pattern
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kaspernj
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: appraisal
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name: pry
|
42
|
+
name: pry-rails
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|