opera 0.7.1 → 0.7.2
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/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/docs/examples/validations.md +4 -1
- data/lib/opera/operation/builder.rb +11 -3
- data/lib/opera/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 63c163c98e2ccace2ca3857308335aadeee1da8993e8445bc32747ce99f4f787
|
|
4
|
+
data.tar.gz: f11c9a69e6617120abe64e30086e377f7fe965d8b1639a4174ace6dcc845d42f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6c2ae76b8fa01855357255fc8e16d1a4a2b1c73eb836039fdc43148322e8e5db0ad024e3a7864c99e7d6b8422a6d4290d1d7bcd907786cbcfb954c08300b3b11
|
|
7
|
+
data.tar.gz: 497b07ebc70c8b1adab72db22a26aa062c71fc6ba29eb02fc7611fe8ce8264d3df8e0bbb40a8433edd414ac10fa209c0f011b29fb85700925ed1e206cfd9b0f0
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Opera Changelog
|
|
2
2
|
|
|
3
|
+
### 0.7.2 - Sep 07, 2026
|
|
4
|
+
|
|
5
|
+
- Extend the automatic `<method>_output` reader to `validate` instructions, so the sanitized/validated output of a `validate :schema` step is readable as `schema_output` in later steps without a manual `context { attr_reader :schema_output }` declaration.
|
|
6
|
+
- Generate automatic `<method>_output` readers for `validate` / `operation` / `operations` instructions nested inside block instructions (`transaction`, `within`, etc.), not only top-level ones.
|
|
7
|
+
|
|
3
8
|
### 0.7.1 - Sep 07, 2026
|
|
4
9
|
|
|
5
10
|
- Automatically define a `<method>_output` reader for every `operation` / `operations` instruction, so the output of an inner operation is readable in later steps without a manual `context { attr_reader :<method>_output }` declaration. The reader returns the value stored at `context[:<method>_output]`, which remains accessible directly as before. If a reader with that name is already declared before the instruction (following the convention of declaring `context` / `params` / `dependencies` above the DSL steps), the manual one is kept and no automatic reader is created.
|
data/Gemfile.lock
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Opera supports `Dry::Validation::Result` and `Opera::Operation::Result` as return types from validate steps. Validations accumulate errors -- all validations run even if earlier ones fail, so the caller gets all errors at once.
|
|
4
4
|
|
|
5
|
+
The output of a `validate` step is stored in context as `:<method_name>_output`, and Opera defines a matching `<method_name>_output` reader automatically, so you can read the sanitized/validated params directly in later steps.
|
|
6
|
+
|
|
5
7
|
## Example with sanitizing parameters
|
|
6
8
|
|
|
7
9
|
```ruby
|
|
@@ -29,7 +31,8 @@ class Profile::Create < Opera::Operation::Base
|
|
|
29
31
|
end
|
|
30
32
|
|
|
31
33
|
def create
|
|
32
|
-
|
|
34
|
+
# `profile_schema_output` is the auto-generated reader for `validate :profile_schema`
|
|
35
|
+
self.profile = current_account.profiles.create(profile_schema_output)
|
|
33
36
|
end
|
|
34
37
|
|
|
35
38
|
def send_email
|
|
@@ -5,7 +5,7 @@ module Opera
|
|
|
5
5
|
module Builder
|
|
6
6
|
INSTRUCTIONS = %I[validate transaction step success finish_if operation operations within always].freeze
|
|
7
7
|
INNER_INSTRUCTIONS = (INSTRUCTIONS - %I[always]).freeze
|
|
8
|
-
OUTPUT_INSTRUCTIONS = %I[operation operations].freeze
|
|
8
|
+
OUTPUT_INSTRUCTIONS = %I[validate operation operations].freeze
|
|
9
9
|
|
|
10
10
|
def self.included(base)
|
|
11
11
|
base.extend(ClassMethods)
|
|
@@ -25,8 +25,9 @@ module Opera
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
check_method_availability!(method) if method
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
entries = InnerBuilder.new.send(instruction, method, **opts, &blk)
|
|
29
|
+
define_output_readers(entries)
|
|
30
|
+
instructions.concat(entries)
|
|
30
31
|
end
|
|
31
32
|
end
|
|
32
33
|
|
|
@@ -35,6 +36,13 @@ module Opera
|
|
|
35
36
|
instructions << { kind: :always, method: method }
|
|
36
37
|
end
|
|
37
38
|
|
|
39
|
+
def define_output_readers(entries)
|
|
40
|
+
entries.each do |entry|
|
|
41
|
+
define_output_reader(entry[:method]) if entry[:method] && OUTPUT_INSTRUCTIONS.include?(entry[:kind])
|
|
42
|
+
define_output_readers(entry[:instructions]) if entry[:instructions]
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
38
46
|
def define_output_reader(method)
|
|
39
47
|
reader = :"#{method}_output"
|
|
40
48
|
return unless instance_methods(false).none?(reader)
|
data/lib/opera/version.rb
CHANGED