iry 0.5.0 → 0.5.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 +4 -4
- data/VERSION +1 -1
- data/package-lock.json +2 -2
- data/package.json +1 -1
- data/rbi/iry.rbi +33 -1
- data/sig/iry.rbs +29 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ca6d5b931545ba2bb0b9f1e9e7ad77da308e7d0ffe8a64d1df2c1e6378cd1a7
|
4
|
+
data.tar.gz: 4747d18e4a249735907597277bad301e9177dffa5aa00e3410355be13d523683
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2b72c6a64b044c606b3940181971a28fd90fdb1ba7859566adb9f5b7ac17f58aa46544908d06715dbc15105972ee0b272ac65d608dd06ee42fd829799c3ff95
|
7
|
+
data.tar.gz: 2f5c703a19785a8e7fc5689354c80b91d3d3658f00a031edbddad7ca06c36094959f494bbc157c8b40bce4fd3655fd37fa5769ec1fc02e6b7c74524118ebc37b
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.1
|
data/package-lock.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "iry",
|
3
|
-
"version": "0.5.
|
3
|
+
"version": "0.5.1",
|
4
4
|
"lockfileVersion": 3,
|
5
5
|
"requires": true,
|
6
6
|
"packages": {
|
7
7
|
"": {
|
8
8
|
"name": "iry",
|
9
|
-
"version": "0.5.
|
9
|
+
"version": "0.5.1",
|
10
10
|
"license": "MIT",
|
11
11
|
"devDependencies": {
|
12
12
|
"conventional-changelog-cli": ">= 3.0.0",
|
data/package.json
CHANGED
data/rbi/iry.rbi
CHANGED
@@ -57,6 +57,15 @@ module Iry
|
|
57
57
|
sig { params(model: Handlers::Model, block: T.untyped).void }
|
58
58
|
def self.handle_constraints(model, &block); end
|
59
59
|
|
60
|
+
# Executes block and in case of constraints violations on `model`, block is
|
61
|
+
# halted, errors are appended to `model` and {StatementInvalid} is raised
|
62
|
+
#
|
63
|
+
# _@param_ `model` — model object for which constraints should be monitored and for which errors should be added to
|
64
|
+
#
|
65
|
+
# _@return_ — returns `model` parameter
|
66
|
+
sig { params(model: Handlers::Model, block: T.untyped).returns(Handlers::Model) }
|
67
|
+
def self.handle_constraints!(model, &block); end
|
68
|
+
|
60
69
|
# Similar to {ActiveRecord::Base#save} but in case of constraint violations,
|
61
70
|
# `false` is returned and `errors` are populated.
|
62
71
|
# Aside from `model`, it takes the same arguments as
|
@@ -77,6 +86,15 @@ module Iry
|
|
77
86
|
sig { params(model: Handlers::Model).returns(T::Boolean) }
|
78
87
|
def self.save!(model); end
|
79
88
|
|
89
|
+
# Similar to {ActiveRecord::Base#destroy} but in case of constraint
|
90
|
+
# violations, `false` is returned and `errors` are populated.
|
91
|
+
#
|
92
|
+
# _@param_ `model` — model to destroy
|
93
|
+
#
|
94
|
+
# _@return_ — the destroyed model
|
95
|
+
sig { params(model: Handlers::Model).returns(Handlers::Model) }
|
96
|
+
def self.destroy(model); end
|
97
|
+
|
80
98
|
# Included in all exceptions triggered by Iry, this allows to rescue any
|
81
99
|
# gem-related exception by rescuing {Iry::Error}
|
82
100
|
module Error
|
@@ -88,6 +106,20 @@ module Iry
|
|
88
106
|
include Iry::Error
|
89
107
|
end
|
90
108
|
|
109
|
+
class StatementInvalid < ActiveRecord::StatementInvalid
|
110
|
+
include Iry::Error
|
111
|
+
end
|
112
|
+
|
113
|
+
# Overrides private API method {ActiveRecord#create_or_update} to handle
|
114
|
+
# constraints and attach errors to the including model
|
115
|
+
module Patch
|
116
|
+
# Takes attributes as named arguments
|
117
|
+
#
|
118
|
+
# _@return_ — true if successful
|
119
|
+
sig { returns(T::Boolean) }
|
120
|
+
def create_or_update; end
|
121
|
+
end
|
122
|
+
|
91
123
|
# Class-level methods available to classes executing `include Iry`
|
92
124
|
module Macros
|
93
125
|
# Constraints by name
|
@@ -207,7 +239,7 @@ module Iry
|
|
207
239
|
exclusion\sconstraint|
|
208
240
|
foreign\skey\sconstraint
|
209
241
|
)
|
210
|
-
\s"(
|
242
|
+
\s"([^"]+)"
|
211
243
|
}x, T.untyped)
|
212
244
|
|
213
245
|
# sord warn - ActiveRecord::StatementInvalid wasn't able to be resolved to a constant in this project
|
data/sig/iry.rbs
CHANGED
@@ -53,6 +53,14 @@ module Iry
|
|
53
53
|
# ```
|
54
54
|
def self.handle_constraints: (Handlers::Model model) -> void
|
55
55
|
|
56
|
+
# Executes block and in case of constraints violations on `model`, block is
|
57
|
+
# halted, errors are appended to `model` and {StatementInvalid} is raised
|
58
|
+
#
|
59
|
+
# _@param_ `model` — model object for which constraints should be monitored and for which errors should be added to
|
60
|
+
#
|
61
|
+
# _@return_ — returns `model` parameter
|
62
|
+
def self.handle_constraints!: (Handlers::Model model) -> Handlers::Model
|
63
|
+
|
56
64
|
# Similar to {ActiveRecord::Base#save} but in case of constraint violations,
|
57
65
|
# `false` is returned and `errors` are populated.
|
58
66
|
# Aside from `model`, it takes the same arguments as
|
@@ -71,6 +79,14 @@ module Iry
|
|
71
79
|
# _@param_ `model` — model to save
|
72
80
|
def self.save!: (Handlers::Model model) -> bool
|
73
81
|
|
82
|
+
# Similar to {ActiveRecord::Base#destroy} but in case of constraint
|
83
|
+
# violations, `false` is returned and `errors` are populated.
|
84
|
+
#
|
85
|
+
# _@param_ `model` — model to destroy
|
86
|
+
#
|
87
|
+
# _@return_ — the destroyed model
|
88
|
+
def self.destroy: (Handlers::Model model) -> Handlers::Model
|
89
|
+
|
74
90
|
# Included in all exceptions triggered by Iry, this allows to rescue any
|
75
91
|
# gem-related exception by rescuing {Iry::Error}
|
76
92
|
module Error
|
@@ -82,6 +98,19 @@ module Iry
|
|
82
98
|
include Iry::Error
|
83
99
|
end
|
84
100
|
|
101
|
+
class StatementInvalid < ActiveRecord::StatementInvalid
|
102
|
+
include Iry::Error
|
103
|
+
end
|
104
|
+
|
105
|
+
# Overrides private API method {ActiveRecord#create_or_update} to handle
|
106
|
+
# constraints and attach errors to the including model
|
107
|
+
module Patch
|
108
|
+
# Takes attributes as named arguments
|
109
|
+
#
|
110
|
+
# _@return_ — true if successful
|
111
|
+
def create_or_update: () -> bool
|
112
|
+
end
|
113
|
+
|
85
114
|
# Class-level methods available to classes executing `include Iry`
|
86
115
|
module Macros
|
87
116
|
# Constraints by name
|