declare_schema 4.0.1.colin.1 → 4.0.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/.ruby-version +1 -1
- data/CHANGELOG.md +1 -1
- data/Gemfile.lock +1 -1
- data/lib/declare_schema/model/deferred_field_spec.rb +1 -2
- data/lib/declare_schema/version.rb +1 -1
- data/spec/lib/declare_schema/deferred_field_spec_spec.rb +17 -19
- metadata +3 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3bff0212d77096ebab36e041956c4c1bb9660cf64782e4a43d3ed259958e13f0
|
|
4
|
+
data.tar.gz: 0db353087c6b118cab88e86f959c1a41ad63a3915338a4fce227a98c65d99c40
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b80feb059afdf5f9582a0895aed29b3251f9a1d29b03b3c82364204ebff919e70166cfe44c243f75abb20bac9ac75d6ae33d98abfb3728759337f6c7ccd0b34f
|
|
7
|
+
data.tar.gz: 29bf01f645154515d89bb66ad54fc28cdd4401a39dca742d714b44c2d0b437e28b2ba61ae228a6ce7614aabb940e7682ac72873d617d8935ac5a80c8686d0fb7
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
3.
|
|
1
|
+
3.3.8
|
data/CHANGELOG.md
CHANGED
|
@@ -4,7 +4,7 @@ Inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
|
4
4
|
|
|
5
5
|
Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
-
## [4.0.1] - 2026-05-
|
|
7
|
+
## [4.0.1] - 2026-05-07
|
|
8
8
|
### Fixed
|
|
9
9
|
- `DeferredFieldSpec` (the lazy stand-in introduced in 4.0.0 for `belongs_to`
|
|
10
10
|
foreign-key field specs) now transparently delegates the `FieldSpec` read
|
data/Gemfile.lock
CHANGED
|
@@ -25,8 +25,7 @@ module DeclareSchema
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
# Resolve and memoize the produced FieldSpec. Memoization matters because
|
|
28
|
-
# application code can hit several FieldSpec accessors per request
|
|
29
|
-
# ModelReport reads `.options`, ApplicationModel reads `.limit`); without
|
|
28
|
+
# application code can hit several FieldSpec accessors per request; without
|
|
30
29
|
# it each one would re-run the resolver and re-touch `reflection.klass`.
|
|
31
30
|
#
|
|
32
31
|
# @return [FieldSpec]
|
|
@@ -36,13 +36,26 @@ RSpec.describe DeclareSchema::Model::DeferredFieldSpec do
|
|
|
36
36
|
|
|
37
37
|
expect(call_count).to eq(1)
|
|
38
38
|
end
|
|
39
|
+
|
|
40
|
+
it 'memoizes the resolver result across many delegated reads' do
|
|
41
|
+
call_count = 0
|
|
42
|
+
deferred = described_class.new(default_spec) do |_|
|
|
43
|
+
call_count += 1
|
|
44
|
+
mirrored_spec
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
deferred.options
|
|
48
|
+
deferred.type
|
|
49
|
+
deferred.limit
|
|
50
|
+
deferred.null
|
|
51
|
+
|
|
52
|
+
expect(call_count).to eq(1)
|
|
53
|
+
end
|
|
39
54
|
end
|
|
40
55
|
|
|
41
|
-
# Application code
|
|
42
|
-
# reads from `field_specs` without first calling `.resolve`. The deferred spec must
|
|
56
|
+
# Application code can read from `field_specs` without first calling `.resolve`. The deferred spec must
|
|
43
57
|
# therefore quack like the resolved FieldSpec; otherwise we get NoMethodError at runtime
|
|
44
|
-
# in apps that read FieldSpec attributes
|
|
45
|
-
# (e.g. :bigint when the parent's PK is actually :integer or :binary).
|
|
58
|
+
# in apps that read FieldSpec attributes.
|
|
46
59
|
describe 'FieldSpec API delegation' do
|
|
47
60
|
let(:deferred) { described_class.new(default_spec) { mirrored_spec } }
|
|
48
61
|
|
|
@@ -65,20 +78,5 @@ RSpec.describe DeclareSchema::Model::DeferredFieldSpec do
|
|
|
65
78
|
it 'reports respond_to? for delegated methods' do
|
|
66
79
|
expect(deferred).to respond_to(:options, :type, :limit, :null, :name, :position)
|
|
67
80
|
end
|
|
68
|
-
|
|
69
|
-
it 'invokes the resolver only once across many delegated reads' do
|
|
70
|
-
call_count = 0
|
|
71
|
-
deferred = described_class.new(default_spec) do |_|
|
|
72
|
-
call_count += 1
|
|
73
|
-
mirrored_spec
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
deferred.options
|
|
77
|
-
deferred.type
|
|
78
|
-
deferred.limit
|
|
79
|
-
deferred.null
|
|
80
|
-
|
|
81
|
-
expect(call_count).to eq(1)
|
|
82
|
-
end
|
|
83
81
|
end
|
|
84
82
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: declare_schema
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.0.1
|
|
4
|
+
version: 4.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Invoca Development adapted from hobo_fields by Tom Locke
|
|
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: rails
|
|
@@ -144,7 +143,6 @@ homepage: https://github.com/Invoca/declare_schema
|
|
|
144
143
|
licenses: []
|
|
145
144
|
metadata:
|
|
146
145
|
allowed_push_host: https://rubygems.org
|
|
147
|
-
post_install_message:
|
|
148
146
|
rdoc_options: []
|
|
149
147
|
require_paths:
|
|
150
148
|
- lib
|
|
@@ -159,8 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
159
157
|
- !ruby/object:Gem::Version
|
|
160
158
|
version: 1.3.6
|
|
161
159
|
requirements: []
|
|
162
|
-
rubygems_version: 3.
|
|
163
|
-
signing_key:
|
|
160
|
+
rubygems_version: 3.6.8
|
|
164
161
|
specification_version: 4
|
|
165
162
|
summary: Database schema declaration and migration generator for Rails
|
|
166
163
|
test_files: []
|