activerecord-mysql-enum 2.2.0 → 2.3.0
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 +5 -0
- data/Gemfile.lock +1 -1
- data/README.md +9 -1
- data/lib/active_record/mysql/enum/mysql_adapter.rb +2 -2
- data/lib/active_record/mysql/enum/version.rb +1 -1
- data/lib/active_record/mysql/enum.rb +16 -10
- 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: 5a31298ed5c99c46cc43f7f7505037b01aae924b9ee711327d1f48c23d00439d
|
4
|
+
data.tar.gz: a2c86f1f9bdb2e0407f7aec6c94cc187020bac9b14e10568a83b0fd1c9103895
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9e47756714d2672b42d981893d8e43b1b9c1b85c7d4ede2c932b3741fc13250c47ab387fcc21beee684bd68c7d8a64c69c7afa2ed1e41f92e11e1aac42623c0
|
7
|
+
data.tar.gz: 6fff0d2528b54ab4e683b1bca7e754667c2b2695098ff9ec4db1e6a737e5103b09d93851229af0a1cfdc757f48d4ecdbe3a6075f6c595991c2aa01d6e9a2b5d3
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,10 @@ 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
|
+
## [2.3.0] - 2022-09-14
|
8
|
+
### Added
|
9
|
+
- Added the ability for non-rails applications to use the gem by using `initialize!` in the application's bootstrapping code after ActiveRecord has been configured.
|
10
|
+
|
7
11
|
## [2.2.0] - 2022-07-18
|
8
12
|
### Added
|
9
13
|
- Added support for Rails 6.1 and 7.0
|
@@ -60,6 +64,7 @@ Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0
|
|
60
64
|
### Changed
|
61
65
|
- Renamed the gem from `enum_column3` to `activerecord-mysql-enum`
|
62
66
|
|
67
|
+
[2.3.0]: https://github.com/Invoca/activerecord-mysql-enum/compare/v2.2.0...v2.3.0
|
63
68
|
[2.2.0]: https://github.com/Invoca/activerecord-mysql-enum/compare/v2.1.0...v2.2.0
|
64
69
|
[2.1.0]: https://github.com/Invoca/activerecord-mysql-enum/compare/v2.0.0...v2.1.0
|
65
70
|
[2.0.0]: https://github.com/Invoca/activerecord-mysql-enum/compare/v1.0.0...v2.0.0
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -7,7 +7,7 @@ which was itself a fork of a fork of Nick Pohodnya's original gem for
|
|
7
7
|
Rails 3, [enum_column3](https://github.com/electronick/enum_column).
|
8
8
|
|
9
9
|
## Support
|
10
|
-
Currently this is tested with
|
10
|
+
Currently this is tested with ActiveRecord version 5.2, 6.0, 6.1, and 7.0.
|
11
11
|
|
12
12
|
**Supported adapters:**
|
13
13
|
- mysql2
|
@@ -18,6 +18,14 @@ In your `Gemfile` add the following snippet
|
|
18
18
|
gem 'activerecord-mysql-enum', '~> 1.0', require: 'active_record/mysql/enum'
|
19
19
|
```
|
20
20
|
|
21
|
+
### Non-Rails Application
|
22
|
+
In order to initialize the extension in non-Rails applications, you must add the following line
|
23
|
+
to your application's bootstrapping code after ActiveRecord has been initialized.
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
ActiveRecord::Mysql::Enum.initialize!
|
27
|
+
```
|
28
|
+
|
21
29
|
## Usage
|
22
30
|
### Schema Definitions
|
23
31
|
When defining an enum in your schema, specify the constraint as a limit:
|
@@ -52,7 +52,7 @@ module ActiveRecord
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
if Gem::Version.new(
|
55
|
+
if Gem::Version.new(ActiveRecord.version) < Gem::Version.new('7.0')
|
56
56
|
private
|
57
57
|
|
58
58
|
def initialize_type_map(m = type_map)
|
@@ -65,7 +65,7 @@ module ActiveRecord
|
|
65
65
|
|
66
66
|
ActiveRecordMysqlAdapter.prepend ActiveRecord::Mysql::Enum::MysqlAdapter
|
67
67
|
|
68
|
-
unless Gem::Version.new(
|
68
|
+
unless Gem::Version.new(ActiveRecord.version) < Gem::Version.new('7.0')
|
69
69
|
[ActiveRecordMysqlAdapter::TYPE_MAP, ActiveRecordMysqlAdapter::TYPE_MAP_WITH_BOOLEAN].each do |m|
|
70
70
|
Enum.register_enum_with_type_mapping(m)
|
71
71
|
end
|
@@ -1,18 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
module
|
5
|
-
module
|
6
|
-
|
3
|
+
module ActiveRecord
|
4
|
+
module Mysql
|
5
|
+
module Enum
|
6
|
+
class << self
|
7
|
+
def initialize!
|
8
|
+
require 'active_record/mysql/enum/mysql_adapter'
|
9
|
+
require 'active_record/mysql/enum/enum_type'
|
10
|
+
require 'active_record/mysql/enum/enum_column_adapter'
|
11
|
+
require 'active_record/mysql/enum/schema_definitions'
|
12
|
+
require 'active_record/mysql/enum/quoting'
|
13
|
+
require 'active_record/mysql/enum/validations'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
if defined?(::Rails::Railtie)
|
7
18
|
class Railtie < Rails::Railtie
|
8
19
|
initializer 'active_record-mysql-enum.initialize', :after => 'active_record.initialize_database' do |app|
|
9
20
|
ActiveSupport.on_load :active_record do
|
10
|
-
|
11
|
-
require 'active_record/mysql/enum/enum_type'
|
12
|
-
require 'active_record/mysql/enum/enum_column_adapter'
|
13
|
-
require 'active_record/mysql/enum/schema_definitions'
|
14
|
-
require 'active_record/mysql/enum/quoting'
|
15
|
-
require 'active_record/mysql/enum/validations'
|
21
|
+
ActiveRecord::Mysql::Enum.initialize!
|
16
22
|
end
|
17
23
|
end
|
18
24
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-mysql-enum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Pohodnya
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-09-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|