enumerize 2.8.0 → 2.8.1

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: 66cd752f1d50a6396a45acd14ddc4f80c34adab4fdb858c48743f9f505b7adfc
4
- data.tar.gz: 387784c9b8c8f5e7c2134900643ddd9465b1159c630ba6f0192bd8599f8deb68
3
+ metadata.gz: 7e8451ec4f75c5a22b6a9c6e337bece407942da5cb12f504b689582e56e1db55
4
+ data.tar.gz: cfd3f27f2fe811d1c23cf47e875da412b76efd0bae55d18f44d551eb56447507
5
5
  SHA512:
6
- metadata.gz: eddef8e043dd39c124b4a3ea946ec0c5a4b820f48e8fc43c46a8a37e8261fce9b3681aa4a2b52e69807d4bea78e3f8a70626728ce360d3d25f1baab996570f11
7
- data.tar.gz: 681e5978eed5021f1c660c81a0574e7c1891285dca0b1468b65c27538b95b320df2ffc486892b241506bb01f867ad18c7f4ccd6d59acc3977e1581c453e86b24
6
+ metadata.gz: ccc0ed4ca53517171dcac492ae9fd618c17fb08b9b39f4f42b6d951cdc46defb3acc92f66ce345fbe13cb0a654db8d7800b4dc72c19cb0c4e3c4ab1c3088780c
7
+ data.tar.gz: bd8521f6e55b9af3283073e36197ea5fc5107d4114f297713b6a27ac221bcd98f2376a4803351eeb8c1a7b518c032b6bcc5d16a6c7750294753d0f64f76a4352
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 2.8.1 (March 25, 2024)
2
+
3
+ ### bug fix
4
+
5
+ * Support enumerization of the same attribute in child classes. (by [@nashby](https://github.com/nashby))
6
+
1
7
  ## 2.8.0 (March 17, 2024)
2
8
 
3
9
  ### bug fix
@@ -124,6 +124,8 @@ module Enumerize
124
124
  end
125
125
 
126
126
  def cast(value)
127
+ return value if @subtype.is_a?(Type)
128
+
127
129
  if value.is_a?(::Enumerize::Value)
128
130
  value
129
131
  else
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Enumerize
4
- VERSION = '2.8.0'
4
+ VERSION = '2.8.1'
5
5
  end
@@ -113,7 +113,7 @@ class User < ActiveRecord::Base
113
113
  enumerize :sex, :in => [:male, :female], scope: :shallow
114
114
  enumerize :language, :in => [:en, :jp]
115
115
 
116
- serialize :interests, Array
116
+ serialize :interests, type: Array
117
117
  enumerize :interests, :in => [:music, :sports, :dancing, :programming], :multiple => true
118
118
 
119
119
  enumerize :status, :in => { active: 1, blocked: 2 }, scope: true
@@ -693,6 +693,15 @@ class ActiveRecordTest < Minitest::Spec
693
693
  expect(user2.skill).must_equal 'casual'
694
694
  end
695
695
 
696
+ it 'works when child class calls enumerize second time' do
697
+ class AdminUser < User
698
+ enumerize :account_type, in: [:basic, :premium, :pro]
699
+ end
700
+
701
+ admin = AdminUser.create(account_type: 'pro')
702
+ expect(admin.account_type).must_equal 'pro'
703
+ end
704
+
696
705
  if Rails::VERSION::MAJOR >= 6
697
706
  it 'supports AR#insert_all' do
698
707
  User.delete_all
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enumerize
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.0
4
+ version: 2.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Nartimov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-17 00:00:00.000000000 Z
11
+ date: 2024-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
117
  requirements: []
118
- rubygems_version: 3.4.7
118
+ rubygems_version: 3.5.3
119
119
  signing_key:
120
120
  specification_version: 4
121
121
  summary: Enumerated attributes with I18n and ActiveRecord/Mongoid/MongoMapper support