typed_operation 1.0.0.beta2 → 1.0.0.beta3

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: 501477c614c107723d1c915099dd06209336708ba5e9672c26622d02a9cd4782
4
- data.tar.gz: b5ab846baf478e3cce3fd8ea1752c04ee708c9a7f84d2be6d47d4c9a94505ac5
3
+ metadata.gz: d6d2e6d373445f7a0c186b88963fb6cadb3947f32731f4411fbeb71588e65d63
4
+ data.tar.gz: 1329be34dbc54ba576c97dae12d82b513696b420ef34885842b6d8b0bb11b643
5
5
  SHA512:
6
- metadata.gz: c3c399b74903b5b9e40ab7838c7d20bafa68969d1200bf2afb11457e41437ae8fa823e7afc14fabe71cd290cd798823f97a0918c4a12d50f6a8768ac1a77ea8e
7
- data.tar.gz: b1ce5f67d1b87ef907f00904288b25edd678a2afab0f68a5f2c5804831f5d05df0fad134a4c28a4893d3867f61c671d548bf687f37b822ff32754355845d9abd
6
+ metadata.gz: d18d142eddd2506739786b89028a952322b0bf0baded051519107e07ed7db4c2444f9134ec1e6471254e7b86549d98a1766379e139bef50d2577c73d634f3c47
7
+ data.tar.gz: bfa38ed9df98fc442e92b9f09ebf2aaf29b5fd3c28e9ccb016c64150c28bb3d42b21409b291258137b2efc2ad8b4e904181877a1e92c7eed1661b29d3f2cdd4d
data/README.md CHANGED
@@ -4,14 +4,7 @@ An implementation of a Command pattern, which is callable, and can be partially
4
4
 
5
5
  Inputs to the operation are specified as typed attributes (uses [`literal`](https://github.com/joeldrapper/literal)).
6
6
 
7
- Type of result of the operation is up to you, eg you could use [`literal` monads](https://github.com/joeldrapper/literal) or [`Dry::Monads`](https://dry-rb.org/gems/dry-monads/1.3/).
8
-
9
- **Note the version described here (~ 1.0.0) is pre-release on Rubygems (v1.0.0 is waiting for a release of `literal`). To use it now you can simply require `literal` from github in your Gemfile:**
10
-
11
- ```ruby
12
- gem "literal", github: "joeldrapper/literal", branch: "main"
13
- gem "typed_operation", "~> 1.0.0.beta2"
14
- ```
7
+ Type of result of the operation is up to you, eg you could use [`Dry::Monads`](https://dry-rb.org/gems/dry-monads/1.3/).
15
8
 
16
9
  ## Features
17
10
 
@@ -177,8 +170,10 @@ Create an operation by subclassing `TypedOperation::Base` or `TypedOperation::Im
177
170
 
178
171
  - `TypedOperation::Base` (uses `Literal::Struct`) is the parent class for an operation where the arguments are potentially mutable (ie not frozen).
179
172
  No attribute writer methods are defined, so the arguments can not be changed after initialization, but the values passed in are not guaranteed to be frozen.
180
- - `TypedOperation::ImmutableBase` (uses `Literal::Data`) is the parent class for an operation where the arguments are immutable (frozen on initialization),
181
- thus giving a somewhat stronger immutability guarantee (ie that the operation does not mutate its arguments).
173
+ - `TypedOperation::ImmutableBase` (uses `Literal::Data`) is the parent class for an operation where the operation instance is frozen on initialization,
174
+ thus giving a somewhat stronger immutability guarantee.
175
+
176
+ > Note: you cannot include `TypedOperation::ActionPolicyAuth` into a `TypedOperation::ImmutableBase`.
182
177
 
183
178
  The subclass must implement the `#perform` method which is where the operations main work is done.
184
179
 
@@ -34,7 +34,7 @@ module TypedOperation
34
34
  raise ArgumentError, "authorize_via must be called with a valid param name" unless via.all? { |param| parameters.include?(param) }
35
35
  @_authorized_via_param = via
36
36
 
37
- action_type_method = "#{action_type}?".to_sym if action_type
37
+ action_type_method = :"#{action_type}?" if action_type
38
38
  # If an method name is provided, use it
39
39
  policy_method = to || action_type_method || raise(::TypedOperation::InvalidOperationError, "You must provide an action type or policy method name")
40
40
  @_policy_method = policy_method
@@ -5,8 +5,12 @@ module TypedOperation
5
5
  # Method to define parameters for your operation.
6
6
  module Parameters
7
7
  # Override literal `prop` to prevent creating writers (Literal::Data does this by default)
8
- def self.prop(name, type, kind = :keyword, reader: :public, writer: :public, default: nil)
9
- super(name, type, kind, reader:, writer: false, default:)
8
+ def prop(name, type, kind = :keyword, reader: :public, writer: :public, default: nil)
9
+ if self < ImmutableBase
10
+ super(name, type, kind, reader:, default:)
11
+ else
12
+ super(name, type, kind, reader:, writer: false, default:)
13
+ end
10
14
  end
11
15
 
12
16
  # Parameter for keyword argument, or a positional argument if you use positional: true
@@ -1,3 +1,3 @@
1
1
  module TypedOperation
2
- VERSION = "1.0.0.beta2"
2
+ VERSION = "1.0.0.beta3"
3
3
  end
@@ -1,7 +1,3 @@
1
- if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("3.2.0")
2
- require "polyfill-data"
3
- end
4
-
5
1
  require "literal"
6
2
 
7
3
  require "typed_operation/version"
metadata CHANGED
@@ -1,15 +1,34 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typed_operation
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta2
4
+ version: 1.0.0.beta3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Ierodiaconou
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-06-24 00:00:00.000000000 Z
12
- dependencies: []
10
+ date: 2025-04-07 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: literal
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: 1.0.0
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: 2.0.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: 1.0.0
29
+ - - "<"
30
+ - !ruby/object:Gem::Version
31
+ version: 2.0.0
13
32
  description: Command pattern, which is callable, and can be partially applied, curried
14
33
  and has typed parameters. Authorization to execute via action_policy if desired.
15
34
  email:
@@ -49,7 +68,6 @@ licenses:
49
68
  metadata:
50
69
  homepage_uri: https://github.com/stevegeek/typed_operation
51
70
  source_code_uri: https://github.com/stevegeek/typed_operation
52
- post_install_message:
53
71
  rdoc_options: []
54
72
  require_paths:
55
73
  - lib
@@ -64,8 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
82
  - !ruby/object:Gem::Version
65
83
  version: '0'
66
84
  requirements: []
67
- rubygems_version: 3.5.3
68
- signing_key:
85
+ rubygems_version: 3.6.2
69
86
  specification_version: 4
70
87
  summary: TypedOperation is a command pattern with typed parameters, which is callable,
71
88
  and can be partially applied.