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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 96981ef35e60c1b498368709d6471d5c880538e0acf3eade1b74e533323fb502
4
- data.tar.gz: 01b10dfe476c603e06a3a17bd5a875d2afbaf536ec4622a4ab885a5a063d5498
3
+ metadata.gz: d7ec1a1bdbbf5c1579ff34c0acdf54220b88ce43e845a4dcbc99ab930f8a6f49
4
+ data.tar.gz: fb09e4e6237d5eb07f028fab2968bbe178775b4b1fdae3d34a23550139b2c7cb
5
5
  SHA512:
6
- metadata.gz: 6f7203eed9b42ee98a5cc9712be296da4983cd2aad28cd2dde4b1679cc1d41db4e3406f8f7e63f3f5b9deb2877c27c2f4d543378f552bfc011125f67ef46aefa
7
- data.tar.gz: 6996d0eb63b2a25ad46f4ca9dad580b2acd750d9f87f98afb0e2123fd76c1e46022095a6e498d3f6867969246cb23ddbaeb93ec6b2fb27b749b335ed3bfbce7e
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
@@ -1,3 +1,3 @@
1
1
  module ServicePattern
2
- VERSION = "1.0.6".freeze
2
+ VERSION = "1.0.7".freeze
3
3
  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.6
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-05-01 00:00:00.000000000 Z
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
  - - ">="