activeinteractor 2.0.0.alpha.4.0.3 → 2.0.0.alpha.4.0.4
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5c6408bdcf2d87a8fcb5fd4eb31a6a65c39daa5a142e2dbea309decc731d472
|
4
|
+
data.tar.gz: 05d8bf464f5d1c2f55de64357e04d894905277da9a5fc96f44a987eef880cdaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d5f4e51c89e4ba941d3a4b4e0c5f62a2dc99188ff95aaa7645025347bce14833c3aaeca7739faf6eb3bc0370f19c108ccee2b2a7b8aafdbc1a64f3875afc3f9
|
7
|
+
data.tar.gz: f3ee81c83b88e54469ded7ba7df55e9ba711f7c3bd1ceff398ecbb215615bea850cd18eaec9bd6c79b39a52f8036f4c2073e6b1431e255cd54364fd19e3c0806
|
@@ -6,12 +6,11 @@ module ActiveInteractor
|
|
6
6
|
NO_DEFAULT_VALUE = :__no_default_value__
|
7
7
|
attr_reader :description, :error_messages, :name
|
8
8
|
|
9
|
-
def initialize(
|
10
|
-
|
9
|
+
def initialize(name, type, description = nil, **options)
|
10
|
+
parse_options(description, options)
|
11
|
+
|
11
12
|
@name = name.to_sym
|
12
13
|
@type_expression = type
|
13
|
-
@description = description || options[:description]
|
14
|
-
@options = { required: false, default: NO_DEFAULT_VALUE }.merge(options)
|
15
14
|
@error_messages = []
|
16
15
|
end
|
17
16
|
|
@@ -44,6 +43,19 @@ module ActiveInteractor
|
|
44
43
|
|
45
44
|
private
|
46
45
|
|
46
|
+
def parse_options(description, options)
|
47
|
+
if description.is_a?(String)
|
48
|
+
@description = description
|
49
|
+
@options = { required: false, default: NO_DEFAULT_VALUE }.merge(options)
|
50
|
+
elsif description.is_a?(Hash)
|
51
|
+
@options = { required: false, default: NO_DEFAULT_VALUE }.merge(description)
|
52
|
+
@description = @options[:description]
|
53
|
+
elsif description.nil?
|
54
|
+
@description = nil
|
55
|
+
@options = { required: false, default: NO_DEFAULT_VALUE }.merge(options)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
47
59
|
def type_is_a_active_interactor_type?
|
48
60
|
type.is_a?(ActiveInteractor::Type::Base) || type.superclass == ActiveInteractor::Type::Base
|
49
61
|
end
|
@@ -55,19 +67,16 @@ module ActiveInteractor
|
|
55
67
|
end
|
56
68
|
|
57
69
|
def validate_type!
|
58
|
-
return true if
|
59
|
-
return true if
|
60
|
-
|
61
|
-
if type_is_a_active_interactor_type?
|
62
|
-
return true if type.valid?(value)
|
63
|
-
|
64
|
-
error_messages << :invalid
|
65
|
-
elsif value.is_a?(type)
|
66
|
-
return true
|
67
|
-
end
|
70
|
+
return true if value_nil_or_untyped?
|
71
|
+
return true if type_is_a_active_interactor_type? && type.valid?(value)
|
72
|
+
return true if value.is_a?(type)
|
68
73
|
|
69
74
|
error_messages << :invalid
|
70
75
|
end
|
76
|
+
|
77
|
+
def value_nil_or_untyped?
|
78
|
+
value.nil? || %i[any untyped].include?(type)
|
79
|
+
end
|
71
80
|
end
|
72
81
|
end
|
73
82
|
end
|
@@ -3,15 +3,14 @@
|
|
3
3
|
module ActiveInteractor
|
4
4
|
module Context
|
5
5
|
class AttributeSet
|
6
|
-
def initialize(
|
7
|
-
@owner = owner
|
6
|
+
def initialize(*attributes)
|
8
7
|
@set = {}
|
9
8
|
attributes.each { |attribute| @set[attribute.name] = attribute }
|
10
9
|
end
|
11
10
|
|
12
11
|
def add(*attribute_args)
|
13
12
|
attribute_options = attribute_args.extract_options!
|
14
|
-
attribute = Attribute.new(
|
13
|
+
attribute = Attribute.new(*attribute_args, **attribute_options)
|
15
14
|
@set[attribute.name] = attribute
|
16
15
|
end
|
17
16
|
|
@@ -18,7 +18,7 @@ module ActiveInteractor
|
|
18
18
|
protected
|
19
19
|
|
20
20
|
def attribute_set
|
21
|
-
@attribute_set ||= AttributeSet.new
|
21
|
+
@attribute_set ||= AttributeSet.new
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -57,7 +57,7 @@ module ActiveInteractor
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def attribute_set
|
60
|
-
@attribute_set ||= AttributeSet.new(
|
60
|
+
@attribute_set ||= AttributeSet.new(*self.class.send(:attribute_set).attributes.map(&:dup))
|
61
61
|
end
|
62
62
|
|
63
63
|
def method_missing(method_name, *arguments)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeinteractor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.alpha.4.0.
|
4
|
+
version: 2.0.0.alpha.4.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Allen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-02
|
11
|
+
date: 2024-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -88,10 +88,10 @@ licenses:
|
|
88
88
|
- MIT
|
89
89
|
metadata:
|
90
90
|
bug_tracker_uri: https://github.com/activeinteractor/activeinteractor/issues
|
91
|
-
changelog_uri: https://github.com/activeinteractor/activeinteractor/blob/v2.0.0-alpha.4.0.
|
91
|
+
changelog_uri: https://github.com/activeinteractor/activeinteractor/blob/v2.0.0-alpha.4.0.4/CHANGELOG.md
|
92
92
|
homepage_uri: https://activeinteractor.org
|
93
|
-
source_code_uri: https://github.com/activeinteractor/activeinteractor/tree/v2.0.0-alpha.4.0.
|
94
|
-
documentation_uri: https://activeinteractor.org/api/activeinteractor/v2.0.0-alpha.4.0.
|
93
|
+
source_code_uri: https://github.com/activeinteractor/activeinteractor/tree/v2.0.0-alpha.4.0.4
|
94
|
+
documentation_uri: https://activeinteractor.org/api/activeinteractor/v2.0.0-alpha.4.0.4
|
95
95
|
wiki_uri: https://github.com/activeinteractor/activeinteractor/wiki
|
96
96
|
rubygems_mfa_required: 'true'
|
97
97
|
post_install_message:
|