validation_errors 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8679caa07860e4574fa21e0ebe978a31405fadb47f5c2ec9bae0b5d2f801e349
4
- data.tar.gz: a5d24ff1ee7c2f2a5f0aea3c0068cb60b2c8467f20f99c67ad57f0a292d0f877
3
+ metadata.gz: 4fed7190ae44232b3441ccaa634450ceefa80ac74dd5615c6b0b58147fc3990d
4
+ data.tar.gz: 3fc056004f5e810c75489c009df26d2bd42f3804d163b3c2bcd2ab85665a50e4
5
5
  SHA512:
6
- metadata.gz: 1e7b20f0989065c49e2f7d42723f962e122e1a899248e1544f0e487bf5e9f4a458b8eea058c94cbeedc5ccacd893a26b8cb041687aed0301fd8e9b40934188d1
7
- data.tar.gz: 24d4b7c52ba5a8514a1583f875124c511bcb9107164cc2c061dfecc33cb6b8c9f5edb06c96612ec661ed395efebe4b354788fa32f1c9a606577d7ee61b6e428c
6
+ metadata.gz: f2fd1b962e6f1dca4fa2cdb6dc672bc45823d1e79e20a1ccbe44f5dc562207e7871c1f5637acfb8698af7c54caad3be70de5b80f44d5bdab501d76825522d11c
7
+ data.tar.gz: 15191622d27d105d9872cd266b9610e6c8e6db98c650aefb0efcd0ef9d833ec1f6ebe00fc7ef101443abac6c959bd099dcc6cc426a0434505bb3653ce6f53d02
data/CHANGELOG.md CHANGED
@@ -1,4 +1,10 @@
1
- ## [Unreleased]
1
+ ## Unreleased
2
+
3
+ - ...
4
+
5
+ ## [0.2.0] - 2022-12-29
6
+
7
+ - Allow to use a custom action name when tracking errors
2
8
 
3
9
  ## [0.1.0] - 2022-09-19
4
10
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- validation_errors (0.1.0)
4
+ validation_errors (0.2.0)
5
5
  activerecord (>= 4.1.0)
6
6
  zeitwerk (>= 2.0.0)
7
7
 
@@ -52,7 +52,7 @@ GEM
52
52
  tzinfo (2.0.5)
53
53
  concurrent-ruby (~> 1.0)
54
54
  unicode-display_width (2.3.0)
55
- zeitwerk (2.6.0)
55
+ zeitwerk (2.6.6)
56
56
 
57
57
  PLATFORMS
58
58
  arm64-darwin-21
data/README.md CHANGED
@@ -72,7 +72,10 @@ def create
72
72
  end
73
73
  ```
74
74
 
75
- Yes, this will execute an additinoal INSERT into your database. Keep it in mind.
75
+ Yes, this will execute an additional INSERT into your database. Keep it in mind.
76
+
77
+ `ValidationError.track(@model)` will automatically detect if the action is `create` or `update`.
78
+ You can also use a custom action name by calling `ValidationError.track(@model, action: 'custom_action')`.
76
79
 
77
80
  ### Automatic
78
81
 
@@ -173,7 +176,7 @@ or, if you have the view above:
173
176
 
174
177
  ```sql
175
178
  select invalid_model_name, error_column, count(*)
176
- from validation_errors_flat
179
+ from flat_validation_errors
177
180
  group by 1, 2
178
181
  ```
179
182
 
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ValidationError < ActiveRecord::Base
4
- def self.track(invalid_model)
4
+ def self.track(invalid_model, action: invalid_model.persisted? ? "update" : "create")
5
5
  create!(invalid_model_name: invalid_model.class.name,
6
6
  invalid_model_id: invalid_model.id,
7
7
  details: invalid_model.errors.details,
8
- action: invalid_model.persisted? ? "update" : "create")
8
+ action: action)
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validation_errors
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alessandro Rodi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-12-08 00:00:00.000000000 Z
11
+ date: 2022-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord