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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ae5c55f72cf9337e2974bc15f8a834d8e2ec8517f092dcd62c986ebcfe81ef22
4
- data.tar.gz: f89c957b5c457d1a3981523dffdc608778a4b3d7e5baeb1c2cbbe10a0f0aacb1
3
+ metadata.gz: 63c163c98e2ccace2ca3857308335aadeee1da8993e8445bc32747ce99f4f787
4
+ data.tar.gz: f11c9a69e6617120abe64e30086e377f7fe965d8b1639a4174ace6dcc845d42f
5
5
  SHA512:
6
- metadata.gz: 9371d589bfa9d5d24cf67d1cbd065aa0622a7e768901fa0430c4510c64934b0a1b13c679cf044554facf9dc53684d597aed3e2ed228b96236642f1edba2b8978
7
- data.tar.gz: c6810a27ce251b4c1db8cf5f2884e49ffd74467d7fb8015d536cef79c646bd1b393401009075515c21a72b64aa036bbe73710b14f93b2ffb3ded561d0ba516e4
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- opera (0.7.1)
4
+ opera (0.7.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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
- self.profile = current_account.profiles.create(context[:profile_schema_output])
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
- define_output_reader(method) if method && OUTPUT_INSTRUCTIONS.include?(instruction)
29
- instructions.concat(InnerBuilder.new.send(instruction, method, **opts, &blk))
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Opera
4
- VERSION = '0.7.1'
4
+ VERSION = '0.7.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opera
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ProFinda Development Team