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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8646e74d05d6f4f22e9999a4146192223fbe1d93e480b9cf6e2a4ac14b29b098
4
- data.tar.gz: 6ab7306d8a5eddfef9f980d12fa9ae8eb9ba6f485b9c345cc88efd71968f6752
3
+ metadata.gz: 9b40a092b72f6361e4693545466f24456c99e8bcb99544b151ea3f2d7fc81dba
4
+ data.tar.gz: 25e7245a8e46d79a7ceb1e7de19c869e8cee5af3aabca774db5bd12e500e6a97
5
5
  SHA512:
6
- metadata.gz: efdbdf46333663b2970af1e116ae9cc86fc0c7b0b557d249bfc0742de51e9dd173059d88d545d49ef9ff7916cee783b37d18ae7faae7e45870938b375690d381
7
- data.tar.gz: cf1fe6ca9eb6921b02a48081c7a2b319293f4816e9fde88ba3608fdcda53dd9e91c6ea798fd0f34caadae0a0818d57f0bc599c0212796c86ad1c8a1ed4b5dcc3
6
+ metadata.gz: 15b0593912cfafd848d498cc9095928e30f925b5e1fdc82c1bdbb0e34e543f5b5f6ae981f003bd9eece9e8f3ab957daaf0b779980002b847bea73296719de286
7
+ data.tar.gz: 7b823c166979fe0786e455a39e81cf633db3784aa91a47e9c34491082489e7a7049e2997c46cc9470830fccab063c7ac693feba97eab897cea995d675cae12ae
@@ -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`
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (2.4.1)
4
+ active_type (2.5.0)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
data/Gemfile.5.2.pg.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (2.4.1)
4
+ active_type (2.5.0)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (2.4.1)
4
+ active_type (2.5.0)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (2.4.1)
4
+ active_type (2.5.0)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
data/Gemfile.6.1.pg.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (2.4.1)
4
+ active_type (2.5.0)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (2.4.1)
4
+ active_type (2.5.0)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
data/Gemfile.7.0.pg.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (2.4.1)
4
+ active_type (2.5.0)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (2.4.1)
4
+ active_type (2.5.0)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -1,3 +1,3 @@
1
1
  module ActiveType
2
- VERSION = '2.4.1'
2
+ VERSION = '2.5.0'
3
3
  end
@@ -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
@@ -21,4 +21,8 @@ module ActiveType
21
21
  # Make Util methods available under the `ActiveType` namespace
22
22
  # like `ActiveType.cast(...)`
23
23
  extend Util
24
+
25
+ def self.deprecator
26
+ @deprecator ||= ActiveSupport::Deprecation.new
27
+ end
24
28
  end
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.1
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-01-08 00:00:00.000000000 Z
12
+ date: 2024-02-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler