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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ffce6e3ac257695994f6047a2fc92014732807c6df5f73e7a50a8c9e43b4dead
4
- data.tar.gz: 3cf2a902e47a9d4077c271802aaa1dd2f9dd382be35ff150537f4432312d4453
3
+ metadata.gz: 5a31298ed5c99c46cc43f7f7505037b01aae924b9ee711327d1f48c23d00439d
4
+ data.tar.gz: a2c86f1f9bdb2e0407f7aec6c94cc187020bac9b14e10568a83b0fd1c9103895
5
5
  SHA512:
6
- metadata.gz: 835337ba0e11f9164608edaca8de311e533eba27ede45944b7a4c323377e1ac96cdb8e3c45f4e9fc227c09568fb6501150e8c5e75bb2042eed33dd7d13f4e873
7
- data.tar.gz: 9d451b8452ec9981942b09d66e568ee0312e1fca635ab454b342c495f15d8c6e3bbfa7f8fbb13d06a99b50b7d05bb4468ec5a1b9e16515e17e140dafaa3e0df3
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- activerecord-mysql-enum (2.2.0)
4
+ activerecord-mysql-enum (2.3.0)
5
5
  activerecord (>= 5.2, < 7.1)
6
6
  mysql2 (>= 0.4.5, < 0.6)
7
7
 
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 Rails version 5.2, 6.0, 6.1, and 7.0.
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(Rails.version) < Gem::Version.new('7.0')
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(Rails.version) < Gem::Version.new('7.0')
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
@@ -3,7 +3,7 @@
3
3
  module ActiveRecord
4
4
  module Mysql
5
5
  module Enum
6
- VERSION = "2.2.0"
6
+ VERSION = "2.3.0"
7
7
  end
8
8
  end
9
9
  end
@@ -1,18 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- if defined?(::Rails::Railtie)
4
- module ActiveRecord
5
- module Mysql
6
- module Enum
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
- require 'active_record/mysql/enum/mysql_adapter'
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.2.0
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-07-18 00:00:00.000000000 Z
12
+ date: 2022-09-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord