interaktor 0.5.0 → 0.6.0.pre
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/README.md +80 -71
- data/interaktor.gemspec +2 -2
- data/lib/interaktor/attributes.rb +24 -0
- data/lib/interaktor/callable.rb +42 -262
- data/lib/interaktor/error/attribute_error.rb +2 -2
- data/lib/interaktor/error/attribute_validation_error.rb +20 -0
- data/lib/interaktor/error/missing_explicit_success_error.rb +7 -2
- data/lib/interaktor/error/organizer_missing_passed_attribute_error.rb +7 -7
- data/lib/interaktor/error/organizer_success_attribute_missing_error.rb +4 -4
- data/lib/interaktor/error/unknown_attribute_error.rb +4 -4
- data/lib/interaktor/interaction.rb +83 -29
- data/lib/interaktor/organizer.rb +7 -35
- data/lib/interaktor.rb +2 -18
- data/spec/interaktor/hooks_spec.rb +357 -363
- data/spec/interaktor/organizer_spec.rb +57 -48
- data/spec/support/helpers.rb +13 -2
- data/spec/support/lint.rb +219 -271
- metadata +11 -11
- data/lib/interaktor/error/attribute_schema_validation_error.rb +0 -54
- data/spec/interaktor/context_spec.rb +0 -187
data/lib/interaktor.rb
CHANGED
|
@@ -15,9 +15,7 @@ module Interaktor
|
|
|
15
15
|
include Hooks
|
|
16
16
|
include Callable
|
|
17
17
|
|
|
18
|
-
interaction_class = Class.new(Interaktor::Interaction)
|
|
19
|
-
end
|
|
20
|
-
|
|
18
|
+
interaction_class = Class.new(Interaktor::Interaction)
|
|
21
19
|
base.const_set(:Interaction, interaction_class)
|
|
22
20
|
end
|
|
23
21
|
end
|
|
@@ -31,23 +29,13 @@ module Interaktor
|
|
|
31
29
|
@interaction = self.class::Interaction.new(self, args)
|
|
32
30
|
end
|
|
33
31
|
|
|
34
|
-
# @param args [Hash
|
|
32
|
+
# @param args [Hash]
|
|
35
33
|
def fail!(args = {})
|
|
36
|
-
if (disallowed_key = args.keys.find { |k| !self.class.failure_attributes.include?(k.to_sym) })
|
|
37
|
-
raise Interaktor::Error::UnknownAttributeError.new(self, disallowed_key)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
self.class.validate_failure_schema(args)
|
|
41
34
|
@interaction.fail!(args)
|
|
42
35
|
end
|
|
43
36
|
|
|
44
37
|
# @param args [Hash]
|
|
45
38
|
def success!(args = {})
|
|
46
|
-
if (disallowed_key = args.keys.find { |k| !self.class.success_attributes.include?(k.to_sym) })
|
|
47
|
-
raise Interaktor::Error::UnknownAttributeError.new(self, disallowed_key)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
self.class.validate_success_schema(args)
|
|
51
39
|
@interaction.success!(args)
|
|
52
40
|
end
|
|
53
41
|
|
|
@@ -87,10 +75,6 @@ module Interaktor
|
|
|
87
75
|
call
|
|
88
76
|
end
|
|
89
77
|
|
|
90
|
-
if self.class.required_success_attributes.any? && !@interaction.success_args
|
|
91
|
-
raise Interaktor::Error::MissingExplicitSuccessError.new(self, self.class.required_success_attributes)
|
|
92
|
-
end
|
|
93
|
-
|
|
94
78
|
@interaction.called!(self)
|
|
95
79
|
end
|
|
96
80
|
rescue
|