opera 0.7.0 → 0.7.1

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: a69b196af65cb01e20f10d595444751505e0a241f6264e00c8de370c05def135
4
- data.tar.gz: b17458445a2f96f47abb45064084498d8e4efb208a2dc04aa1e4abba1d2ab7ee
3
+ metadata.gz: ae5c55f72cf9337e2974bc15f8a834d8e2ec8517f092dcd62c986ebcfe81ef22
4
+ data.tar.gz: f89c957b5c457d1a3981523dffdc608778a4b3d7e5baeb1c2cbbe10a0f0aacb1
5
5
  SHA512:
6
- metadata.gz: f4531f3b0cea01d642df058dc6a956de5e036b1259dd2dff659b4a67dc0956a34e965032442860b3b03af1997e1af9a41fe18845fbff4a13ef04a22f11adddc1
7
- data.tar.gz: ea82fa32434682ec8f9dbbe3754204c3b9edcd586a64805debee5332ef05a69ef913523e309bf729bff626fa21eb79383058740bd3d9ee2cc5a7770f82c710d1
6
+ metadata.gz: 9371d589bfa9d5d24cf67d1cbd065aa0622a7e768901fa0430c4510c64934b0a1b13c679cf044554facf9dc53684d597aed3e2ed228b96236642f1edba2b8978
7
+ data.tar.gz: c6810a27ce251b4c1db8cf5f2884e49ffd74467d7fb8015d536cef79c646bd1b393401009075515c21a72b64aa036bbe73710b14f93b2ffb3ded561d0ba516e4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Opera Changelog
2
2
 
3
+ ### 0.7.1 - Sep 07, 2026
4
+
5
+ - 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.
6
+
3
7
  ### 0.7.0 - Apr 30, 2026
4
8
 
5
9
  - Add `:if` / `:unless` options to all instructions except `always` (`validate`, `transaction`, `step`, `success`, `finish_if`, `operation`, `operations`, `within`) for declarative conditional execution. Conditions accept a Symbol (method name) or a Proc/Lambda (evaluated via `instance_exec` in the operation instance scope). Skipped instructions do not execute and are not recorded in `result.executions`; for block instructions (`transaction`, `within`) the whole block, including nested instructions, is skipped. For `operation` / `operations`, the conventional `<method>_output` slot in context is set to `nil` when skipped, matching the historical `return Opera::Operation::Result.new` early-exit behavior. Passing both `:if` and `:unless` on the same instruction raises `ArgumentError` at class load time.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- opera (0.7.0)
4
+ opera (0.7.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -4,6 +4,8 @@
4
4
 
5
5
  Use `operation` to call another Opera operation from within a step. The method must return an `Opera::Operation::Result`. If the inner operation fails, errors are propagated and execution stops. If it succeeds, its output is stored in context as `:<method_name>_output`.
6
6
 
7
+ Opera also defines a `<method_name>_output` reader automatically, so you can access the output directly in later steps without declaring `context { attr_reader :<method_name>_output }` yourself. Both `context[:<method_name>_output]` and the reader return the same value.
8
+
7
9
  ```ruby
8
10
  class Profile::Find < Opera::Operation::Base
9
11
  step :find
@@ -33,12 +35,13 @@ class Profile::Create < Opera::Operation::Base
33
35
  end
34
36
 
35
37
  def create
36
- return if context[:find_output]
38
+ # `find_output` is the auto-generated reader for `operation :find`
39
+ return if find_output
37
40
  puts 'not found'
38
41
  end
39
42
 
40
43
  def output
41
- result.output = { model: context[:find_output] }
44
+ result.output = { model: find_output }
42
45
  end
43
46
  end
44
47
  ```
@@ -82,7 +85,8 @@ class Profile::CreateMultiple < Opera::Operation::Base
82
85
  end
83
86
 
84
87
  def output
85
- result.output = context[:create_multiple_output]
88
+ # `create_multiple_output` is the auto-generated reader for `operations :create_multiple`
89
+ result.output = create_multiple_output
86
90
  end
87
91
  end
88
92
  ```
@@ -5,6 +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
9
 
9
10
  def self.included(base)
10
11
  base.extend(ClassMethods)
@@ -24,6 +25,7 @@ module Opera
24
25
  end
25
26
 
26
27
  check_method_availability!(method) if method
28
+ define_output_reader(method) if method && OUTPUT_INSTRUCTIONS.include?(instruction)
27
29
  instructions.concat(InnerBuilder.new.send(instruction, method, **opts, &blk))
28
30
  end
29
31
  end
@@ -32,6 +34,13 @@ module Opera
32
34
  check_method_availability!(method)
33
35
  instructions << { kind: :always, method: method }
34
36
  end
37
+
38
+ def define_output_reader(method)
39
+ reader = :"#{method}_output"
40
+ return unless instance_methods(false).none?(reader)
41
+
42
+ context { attr_reader(reader) }
43
+ end
35
44
  end
36
45
 
37
46
  class InnerBuilder
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.0'
4
+ VERSION = '0.7.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opera
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ProFinda Development Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-07-14 00:00:00.000000000 Z
11
+ date: 2026-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-validation