activerecord-changesets 1.0.1 → 1.0.3
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/CHANGELOG.md +7 -0
- data/lib/{active_record_changesets.rb → activerecord-changesets.rb} +10 -7
- metadata +7 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 64ca66e8e53bd6be5217e42625b28f16d698311bd13bebb91dbfbf3bced7b8a8
|
|
4
|
+
data.tar.gz: 1c9ac27b0bc64fd88e49d1bd0dd5fbb19d69b88faaaae2ae790d726b09f31209
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d8d2f54cb445dd7aa6612dfde53c0e4fd77312605d937dfb31a3d226995adb07aa00d4576d31193d8ba1e7662d730ee101348ae5c81cc13ae043b0dcdafe1b6a
|
|
7
|
+
data.tar.gz: 7c5d5890b032200c40af95368e42e18f74f6d5591bfddc3ef0a6ab9a39a90fbc51b2726969efcff0f8ce6beb79072941915796dce9ac8d40d7bee4333274ce24
|
data/CHANGELOG.md
CHANGED
|
@@ -26,13 +26,13 @@ require "active_support/core_ext/module/attribute_accessors"
|
|
|
26
26
|
module ActiveRecordChangesets
|
|
27
27
|
# Base error for all gem-specific exceptions
|
|
28
28
|
class Error < StandardError; end
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
# Raised when required parameters are missing while building/assigning a changeset
|
|
31
31
|
class MissingParametersError < Error; end
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
# Raised when strict mode is enabled and unexpected parameters are provided
|
|
34
34
|
class StrictParametersError < Error; end
|
|
35
|
-
|
|
35
|
+
|
|
36
36
|
# Raised when requesting an undefined changeset
|
|
37
37
|
class UnknownChangeset < Error; end
|
|
38
38
|
|
|
@@ -40,7 +40,7 @@ module ActiveRecordChangesets
|
|
|
40
40
|
# attributes in strict mode. Defaults to Rails form helpers params.
|
|
41
41
|
# @return [Array<Symbol>]
|
|
42
42
|
mattr_accessor :ignored_attributes, default: [:authenticity_token, :_method]
|
|
43
|
-
|
|
43
|
+
|
|
44
44
|
# Global default for strict mode. If true, changesets will reject any
|
|
45
45
|
# parameters not explicitly expected/permitted. Can be overridden per changeset.
|
|
46
46
|
# @return [Boolean]
|
|
@@ -56,7 +56,7 @@ module ActiveRecordChangesets
|
|
|
56
56
|
base.class_attribute :_changesets, default: {}
|
|
57
57
|
base.private_class_method :_changesets, :_changesets=
|
|
58
58
|
|
|
59
|
-
base.class_attribute :_changeset_mutex, instance_accessor: false, default:
|
|
59
|
+
base.class_attribute :_changeset_mutex, instance_accessor: false, default: Monitor.new
|
|
60
60
|
base.private_class_method :_changeset_mutex, :_changeset_mutex=
|
|
61
61
|
|
|
62
62
|
base.const_set(:Changesets, Module.new)
|
|
@@ -151,7 +151,6 @@ module ActiveRecordChangesets
|
|
|
151
151
|
end
|
|
152
152
|
end
|
|
153
153
|
|
|
154
|
-
|
|
155
154
|
# Resolve or build the concrete changeset class for the given name.
|
|
156
155
|
# The class is built lazily and cached. Thread-safe via a mutex.
|
|
157
156
|
# @param name [Symbol, String]
|
|
@@ -167,7 +166,7 @@ module ActiveRecordChangesets
|
|
|
167
166
|
# observing a Proc and building two distinct classes
|
|
168
167
|
return _changesets[name][:class] if _changesets[name][:class].present?
|
|
169
168
|
|
|
170
|
-
|
|
169
|
+
build_changeset_class(name)
|
|
171
170
|
end
|
|
172
171
|
end
|
|
173
172
|
|
|
@@ -299,6 +298,10 @@ module ActiveRecordChangesets
|
|
|
299
298
|
end
|
|
300
299
|
end
|
|
301
300
|
changeset_class.changeset_options = _changesets[name][:options]
|
|
301
|
+
|
|
302
|
+
# Set the cached class before evaluating the DSL to avoid race conditions
|
|
303
|
+
_changesets[name][:class] = changeset_class
|
|
304
|
+
|
|
302
305
|
changeset_class.class_eval(&_changesets[name][:dsl_proc])
|
|
303
306
|
_changesets[name].delete :dsl_proc
|
|
304
307
|
|
metadata
CHANGED
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: activerecord-changesets
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Simon J
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: activerecord
|
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
|
16
15
|
requirements:
|
|
17
|
-
- - "
|
|
16
|
+
- - ">="
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
18
|
version: '8.0'
|
|
20
19
|
type: :runtime
|
|
21
20
|
prerelease: false
|
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
22
|
requirements:
|
|
24
|
-
- - "
|
|
23
|
+
- - ">="
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
25
|
version: '8.0'
|
|
27
26
|
- !ruby/object:Gem::Dependency
|
|
@@ -137,7 +136,7 @@ dependencies:
|
|
|
137
136
|
- !ruby/object:Gem::Version
|
|
138
137
|
version: '2.14'
|
|
139
138
|
description: Instead of scattering validations, strong parameters, and business rules
|
|
140
|
-
across controllers and models, changesets give you one clear
|
|
139
|
+
across controllers and models, changesets give you one clear interface for handling
|
|
141
140
|
data before it touches the database.
|
|
142
141
|
email: 2857218+mwnciau@users.noreply.github.com
|
|
143
142
|
executables: []
|
|
@@ -147,7 +146,7 @@ files:
|
|
|
147
146
|
- CHANGELOG.md
|
|
148
147
|
- LICENSE.md
|
|
149
148
|
- README.md
|
|
150
|
-
- lib/
|
|
149
|
+
- lib/activerecord-changesets.rb
|
|
151
150
|
homepage: https://rubygems.org/gems/activerecord-changesets
|
|
152
151
|
licenses:
|
|
153
152
|
- MIT
|
|
@@ -156,7 +155,6 @@ metadata:
|
|
|
156
155
|
changelog_uri: https://github.com/mwnciau/activerecord-changesets/blob/main/CHANGELOG.md
|
|
157
156
|
documentation_uri: https://github.com/mwnciau/activerecord-changesets
|
|
158
157
|
bug_tracker_uri: https://github.com/mwnciau/activerecord-changesets/issues
|
|
159
|
-
post_install_message:
|
|
160
158
|
rdoc_options: []
|
|
161
159
|
require_paths:
|
|
162
160
|
- lib
|
|
@@ -171,8 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
171
169
|
- !ruby/object:Gem::Version
|
|
172
170
|
version: '0'
|
|
173
171
|
requirements: []
|
|
174
|
-
rubygems_version: 3.
|
|
175
|
-
signing_key:
|
|
172
|
+
rubygems_version: 3.6.7
|
|
176
173
|
specification_version: 4
|
|
177
174
|
summary: Make your model updates explicit and predictable using changesets
|
|
178
175
|
test_files: []
|