active_type 2.4.1 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +1 -6
- data/CHANGELOG.md +4 -0
- data/Gemfile.5.2.mysql2.lock +1 -1
- data/Gemfile.5.2.pg.lock +1 -1
- data/Gemfile.5.2.sqlite3.lock +1 -1
- data/Gemfile.6.0.sqlite3.lock +1 -1
- data/Gemfile.6.1.pg.lock +1 -1
- data/Gemfile.6.1.sqlite3.lock +1 -1
- data/Gemfile.7.0.pg.lock +1 -1
- data/Gemfile.7.0.sqlite3.lock +1 -1
- data/lib/active_type/version.rb +1 -1
- data/lib/active_type/virtual_attributes.rb +7 -0
- data/lib/active_type.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b40a092b72f6361e4693545466f24456c99e8bcb99544b151ea3f2d7fc81dba
|
4
|
+
data.tar.gz: 25e7245a8e46d79a7ceb1e7de19c869e8cee5af3aabca774db5bd12e500e6a97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15b0593912cfafd848d498cc9095928e30f925b5e1fdc82c1bdbb0e34e543f5b5f6ae981f003bd9eece9e8f3ab957daaf0b779980002b847bea73296719de286
|
7
|
+
data.tar.gz: 7b823c166979fe0786e455a39e81cf633db3784aa91a47e9c34491082489e7a7049e2997c46cc9470830fccab063c7ac693feba97eab897cea995d675cae12ae
|
data/.github/workflows/test.yml
CHANGED
@@ -87,6 +87,7 @@ jobs:
|
|
87
87
|
image: postgres
|
88
88
|
env:
|
89
89
|
POSTGRES_PASSWORD: postgres
|
90
|
+
POSTGRES_DB: active_type_test
|
90
91
|
options: >-
|
91
92
|
--health-cmd pg_isready
|
92
93
|
--health-interval 10s
|
@@ -116,16 +117,10 @@ jobs:
|
|
116
117
|
|
117
118
|
steps:
|
118
119
|
- uses: actions/checkout@v3
|
119
|
-
- name: Install database client
|
120
|
-
run: |
|
121
|
-
sudo apt-get install -y postgresql-client
|
122
120
|
- name: Install ruby
|
123
121
|
uses: ruby/setup-ruby@v1
|
124
122
|
with:
|
125
123
|
ruby-version: ${{ matrix.ruby }}
|
126
124
|
bundler-cache: true
|
127
|
-
- name: Setup databases
|
128
|
-
run: |
|
129
|
-
PGPASSWORD=postgres psql -c 'create database active_type_test;' -U postgres -p 5432 -h localhost
|
130
125
|
- name: Run tests
|
131
126
|
run: bundle exec rake spec
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
+
## 2.5.0 (2024-02-29)
|
6
|
+
|
7
|
+
* Passing unfrozen objects as a default for an attribute is deprecated, since these objects might be shared between records.
|
8
|
+
|
5
9
|
## 2.4.1 (2024-01-08)
|
6
10
|
|
7
11
|
* Fixed: Calling `#attributes` on the base record after a cast works now and does not throw a `MutationAfterCastError`
|
data/Gemfile.5.2.mysql2.lock
CHANGED
data/Gemfile.5.2.pg.lock
CHANGED
data/Gemfile.5.2.sqlite3.lock
CHANGED
data/Gemfile.6.0.sqlite3.lock
CHANGED
data/Gemfile.6.1.pg.lock
CHANGED
data/Gemfile.6.1.sqlite3.lock
CHANGED
data/Gemfile.7.0.pg.lock
CHANGED
data/Gemfile.7.0.sqlite3.lock
CHANGED
data/lib/active_type/version.rb
CHANGED
@@ -54,6 +54,7 @@ module ActiveType
|
|
54
54
|
def build(name, type, options)
|
55
55
|
validate_attribute_name!(name)
|
56
56
|
options.assert_valid_keys(:default)
|
57
|
+
deprecate_non_frozen_defaults(options[:default], name)
|
57
58
|
add_virtual_column(name, type, options)
|
58
59
|
build_reader(name)
|
59
60
|
build_writer(name)
|
@@ -68,6 +69,12 @@ module ActiveType
|
|
68
69
|
@owner.virtual_columns_hash = @owner.virtual_columns_hash.merge(name.to_s => column)
|
69
70
|
end
|
70
71
|
|
72
|
+
def deprecate_non_frozen_defaults(default, name)
|
73
|
+
unless default.respond_to?(:call) || default.frozen?
|
74
|
+
ActiveType.deprecator.warn("##{name}: Passing a non-frozen object as a default is deprecated. Mutating the attribute can change the default for other records. You can also wrap it in a proc.", caller_locations(3))
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
71
78
|
def build_reader(name)
|
72
79
|
@module.module_eval <<-BODY, __FILE__, __LINE__ + 1
|
73
80
|
def #{name}
|
data/lib/active_type.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_type
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Kraze
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-
|
12
|
+
date: 2024-02-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|