rails_ops 1.7.2 → 1.7.4
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/.github/workflows/ruby.yml +0 -4
- data/Appraisals +3 -0
- data/CHANGELOG.md +15 -0
- data/CLAUDE.md +83 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +7 -2
- data/LICENSE +1 -1
- data/README.md +452 -105
- data/VERSION +1 -1
- data/gemfiles/rails_6.0.gemfile +2 -0
- data/gemfiles/rails_6.1.gemfile +2 -0
- data/gemfiles/rails_7.0.gemfile +2 -0
- data/gemfiles/rails_7.1.gemfile +1 -0
- data/gemfiles/rails_7.2.gemfile +1 -0
- data/gemfiles/rails_8.0.gemfile +1 -0
- data/lib/rails_ops/mixins/model/nesting.rb +5 -0
- data/lib/rails_ops/mixins/policies.rb +8 -0
- data/lib/rails_ops/mixins/schema_validation.rb +6 -1
- data/rails_ops.gemspec +4 -4
- data/test/unit/rails_ops/mixins/policies_test.rb +93 -0
- data/test/unit/rails_ops/operation_test.rb +43 -0
- metadata +4 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 169b4c4d321feeff0cbde6cadc19a2cc09f07477105bc5fccb646cc625941fab
|
|
4
|
+
data.tar.gz: 6ca7942b59db7b7afbff04d7f27ee914615251280b7e9c62c1959e2a3f445cee
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e078b5b60ab4fb49014d020795fb1bf6d9cd62dc76335182ce2c68b90ea9b694e3b13dff3e73f3ff0c4deaca55d704c35ac519c95bcab0f036011097df7c8e46
|
|
7
|
+
data.tar.gz: 2c7fc723a11dc321e096566180b7a6b73ed8d71e612167cce58bfe9f8f65f66f48cb7c5a0f711d806624035bb63a70acaf49cd1752d6c9e36811816d8ea27390
|
data/.github/workflows/ruby.yml
CHANGED
|
@@ -29,8 +29,6 @@ jobs:
|
|
|
29
29
|
ruby-version: '3.2.0'
|
|
30
30
|
- rails-version: '7.1'
|
|
31
31
|
ruby-version: '2.7.8'
|
|
32
|
-
- rails-version: '7.1'
|
|
33
|
-
ruby-version: '3.0.1'
|
|
34
32
|
- rails-version: '7.1'
|
|
35
33
|
ruby-version: '3.1.0'
|
|
36
34
|
- rails-version: '7.1'
|
|
@@ -41,8 +39,6 @@ jobs:
|
|
|
41
39
|
ruby-version: '3.2.0'
|
|
42
40
|
- rails-version: '8.0'
|
|
43
41
|
ruby-version: '3.3.0'
|
|
44
|
-
- rails-version: '8.0'
|
|
45
|
-
ruby-version: '3.4.0'
|
|
46
42
|
name: Test against Ruby ${{ matrix.ruby-version }} / Rails ${{ matrix.rails-version }}
|
|
47
43
|
env:
|
|
48
44
|
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rails_${{ matrix.rails-version }}.gemfile
|
data/Appraisals
CHANGED
|
@@ -13,12 +13,15 @@ end
|
|
|
13
13
|
|
|
14
14
|
appraise 'rails-7.0' do
|
|
15
15
|
gem 'rails', '~> 7.0.1'
|
|
16
|
+
gem 'active_type', '< 2.7.0'
|
|
16
17
|
end
|
|
17
18
|
|
|
18
19
|
appraise 'rails-6.1' do
|
|
19
20
|
gem 'rails', '~> 6.1.4'
|
|
21
|
+
gem 'active_type', '< 2.7.0'
|
|
20
22
|
end
|
|
21
23
|
|
|
22
24
|
appraise 'rails-6.0' do
|
|
23
25
|
gem 'rails', '~> 6.0.4'
|
|
26
|
+
gem 'active_type', '< 2.7.0'
|
|
24
27
|
end
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.7.4 (2026-02-18)
|
|
4
|
+
|
|
5
|
+
* Add `:before_model_validation` policy chain for model operations that runs
|
|
6
|
+
right before `model.validate!`, suitable for attribute cleanup and
|
|
7
|
+
sanitization.
|
|
8
|
+
* Improve README documentation for transactions section: clarify that RailsOps
|
|
9
|
+
model operations do not automatically start transactions
|
|
10
|
+
* Fix STI example in README to correctly show `op.model.class` instead of
|
|
11
|
+
`op_bird.class`
|
|
12
|
+
* Fix incorrect `nest_model_op` example in nested operations documentation
|
|
13
|
+
|
|
14
|
+
## 1.7.3 (2025-05-21)
|
|
15
|
+
|
|
16
|
+
* Allow defining empty schemas via `schema2` method
|
|
17
|
+
|
|
3
18
|
## 1.7.2 (2025-04-14)
|
|
4
19
|
|
|
5
20
|
* Add lazy load hooks
|
data/CLAUDE.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Commands
|
|
6
|
+
|
|
7
|
+
### Build and test
|
|
8
|
+
- `bundle exec rake test` - Run the complete test suite
|
|
9
|
+
- `bundle exec rake test TEST=test/unit/path/to/test.rb` - Run a specific test file
|
|
10
|
+
- `bundle exec rake test TEST=test/unit/path/to/test.rb TESTOPTS="--name=test_name"` - Run a single test
|
|
11
|
+
- `bundle exec rubocop` - Run code linting with RuboCop
|
|
12
|
+
- `bundle exec rubocop -a` - Auto-fix RuboCop violations where possible
|
|
13
|
+
- `bundle install` - Install dependencies
|
|
14
|
+
- `bundle exec appraisal install` - Install dependencies for all Rails versions
|
|
15
|
+
- `bundle exec appraisal rails_X.Y rake test` - Test against specific Rails version (e.g., rails_7.1)
|
|
16
|
+
|
|
17
|
+
## Architecture Overview
|
|
18
|
+
|
|
19
|
+
RailsOps is a service layer gem for Rails applications that implements the Operation pattern. It provides a consistent way to encapsulate business logic in testable, reusable classes.
|
|
20
|
+
|
|
21
|
+
### Core Components
|
|
22
|
+
|
|
23
|
+
1. **Operations** (`lib/rails_ops/operation.rb`)
|
|
24
|
+
- Base class for all operations
|
|
25
|
+
- Handles params validation via Schemacop
|
|
26
|
+
- Includes authorization, policies, and sub-operations
|
|
27
|
+
- Key methods: `run`, `run!`, `perform`
|
|
28
|
+
|
|
29
|
+
2. **Model Operations** (`lib/rails_ops/operation/model/`)
|
|
30
|
+
- `Load` - Loads a model by ID with optional locking
|
|
31
|
+
- `Create` - Creates new model instances
|
|
32
|
+
- `Update` - Updates existing models
|
|
33
|
+
- `Destroy` - Destroys models
|
|
34
|
+
- Supports nested model operations and STI
|
|
35
|
+
|
|
36
|
+
3. **Context** (`lib/rails_ops/context.rb`)
|
|
37
|
+
- Carries request-specific data (user, session, ability, etc.)
|
|
38
|
+
- Automatically passed to sub-operations
|
|
39
|
+
- Used for authorization and access control
|
|
40
|
+
|
|
41
|
+
4. **Controller Integration** (`lib/rails_ops/controller_mixin.rb`)
|
|
42
|
+
- Provides `op` and `run`/`run!` helpers
|
|
43
|
+
- Automatic context creation
|
|
44
|
+
- Authorization checking in after_action
|
|
45
|
+
|
|
46
|
+
5. **Authorization** (`lib/rails_ops/mixins/authorization.rb`)
|
|
47
|
+
- Backend-agnostic authorization
|
|
48
|
+
- Supports CanCanCan out of the box
|
|
49
|
+
- Per-operation and per-param authorization
|
|
50
|
+
|
|
51
|
+
6. **Hooks** (`lib/rails_ops/hookup.rb`)
|
|
52
|
+
- Allows operations to trigger other operations
|
|
53
|
+
- Configured in `config/hookup.rb`
|
|
54
|
+
- Useful for decoupled side effects
|
|
55
|
+
|
|
56
|
+
### Operation Structure
|
|
57
|
+
|
|
58
|
+
Operations should:
|
|
59
|
+
- Live in `app/operations/` (or custom namespace)
|
|
60
|
+
- Have a schemacop schema
|
|
61
|
+
- Be named after actions (e.g., `Create`, not `Creator`)
|
|
62
|
+
- Use proper namespacing (e.g., `Operations::User::Create`)
|
|
63
|
+
- Define schemas for param validation
|
|
64
|
+
- Override `perform` method for business logic
|
|
65
|
+
- Use policies for pre/post checks
|
|
66
|
+
|
|
67
|
+
### Testing Patterns
|
|
68
|
+
|
|
69
|
+
- Test files mirror operation structure in `test/unit/`
|
|
70
|
+
- Use minitest framework
|
|
71
|
+
- Test coverage tracked with SimpleCov
|
|
72
|
+
- CI tests against Ruby 2.7-3.4 and Rails 6.0-8.0
|
|
73
|
+
|
|
74
|
+
### Development Guidelines
|
|
75
|
+
|
|
76
|
+
- Follow RuboCop rules in `.rubocop.yml`
|
|
77
|
+
- Keep operations focused on single responsibilities
|
|
78
|
+
- Use sub-operations for complex workflows
|
|
79
|
+
- Document authorization requirements
|
|
80
|
+
- Ensure thread-safety (avoid runtime model definitions)
|
|
81
|
+
- Wrap lines in markdown files to 80 characters whenever possible
|
|
82
|
+
- Remove any trailing whitespace from any lines (ruby, markdown and javascript),
|
|
83
|
+
also from otherwise empty lines
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
rails_ops (1.7.
|
|
4
|
+
rails_ops (1.7.4)
|
|
5
5
|
active_type (>= 1.3.0)
|
|
6
6
|
minitest
|
|
7
7
|
rails (> 4)
|
|
@@ -125,7 +125,7 @@ GEM
|
|
|
125
125
|
marcel (1.0.4)
|
|
126
126
|
method_source (1.0.0)
|
|
127
127
|
mini_mime (1.1.5)
|
|
128
|
-
minitest (5.
|
|
128
|
+
minitest (5.27.0)
|
|
129
129
|
mutex_m (0.2.0)
|
|
130
130
|
net-imap (0.4.10)
|
|
131
131
|
date
|
|
@@ -137,6 +137,8 @@ GEM
|
|
|
137
137
|
net-smtp (0.4.0.1)
|
|
138
138
|
net-protocol
|
|
139
139
|
nio4r (2.7.0)
|
|
140
|
+
nokogiri (1.16.5-arm64-darwin)
|
|
141
|
+
racc (~> 1.4)
|
|
140
142
|
nokogiri (1.16.5-x86_64-darwin)
|
|
141
143
|
racc (~> 1.4)
|
|
142
144
|
nokogiri (1.16.5-x86_64-linux)
|
|
@@ -227,6 +229,7 @@ GEM
|
|
|
227
229
|
actionpack (>= 5.2)
|
|
228
230
|
activesupport (>= 5.2)
|
|
229
231
|
sprockets (>= 3.0.0)
|
|
232
|
+
sqlite3 (1.6.2-arm64-darwin)
|
|
230
233
|
sqlite3 (1.6.2-x86_64-darwin)
|
|
231
234
|
sqlite3 (1.6.2-x86_64-linux)
|
|
232
235
|
stringio (3.1.0)
|
|
@@ -244,6 +247,7 @@ GEM
|
|
|
244
247
|
zeitwerk (2.6.13)
|
|
245
248
|
|
|
246
249
|
PLATFORMS
|
|
250
|
+
arm64-darwin-24
|
|
247
251
|
x86_64-darwin-20
|
|
248
252
|
x86_64-darwin-21
|
|
249
253
|
x86_64-darwin-22
|
|
@@ -254,6 +258,7 @@ DEPENDENCIES
|
|
|
254
258
|
appraisal
|
|
255
259
|
bundler
|
|
256
260
|
cancancan
|
|
261
|
+
minitest (~> 5.25)
|
|
257
262
|
pry
|
|
258
263
|
rails_ops!
|
|
259
264
|
rake
|