validates_lengths_from_database 1.0.0 → 1.0.1
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b858050297bdf446939c8671bc1b2260345e6bc223762cb0a533264e8dce2b1a
|
|
4
|
+
data.tar.gz: a5f5f3f169cb2919f1bedd7baa548cebb4a75730ca953280636e4f1fa3058a73
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0d704d3980c28cbca2d1c09936d664e02d457ad311b570c1e01c5ca247b7e43129d90b8c82b8edb6c22978971a0a3c96e3dcf49e1791b06f33d9ec7db61b8e2a
|
|
7
|
+
data.tar.gz: b5b2d7c0c087479073b8b983c2dbc067531802a9f86b4eea76e72ec6d36e96bc85b34d01125ea3bb7316172e6fae8751b2a1c10ad58ef472bd7fa36caf8e1992
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v1.0.1 (unreleased)
|
|
4
|
+
|
|
5
|
+
- Add `validates_lengths_from_database` to ActiveRecord::Base whenever the gem is required, so it works without Rails and no longer depends on Rails being loaded first (#23)
|
|
6
|
+
|
|
3
7
|
## v1.0.0 (2026-10-14)
|
|
4
8
|
|
|
5
9
|
- Require Rails (ActiveRecord) 6.1+ and Ruby 2.7+. Apps on older versions can stay on 0.8.x.
|
|
@@ -1,20 +1,9 @@
|
|
|
1
1
|
module ValidatesLengthsFromDatabase
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class Railtie < Rails::Railtie
|
|
6
|
-
initializer "validates_lengths_from_database.extend_active_record" do
|
|
7
|
-
ActiveSupport.on_load(:active_record) do
|
|
8
|
-
ValidatesLengthsFromDatabase::Railtie.insert
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
2
|
+
# Kept for apps that call Railtie.insert themselves. Requiring the gem now
|
|
3
|
+
# adds it to ActiveRecord::Base, so this is no longer needed.
|
|
14
4
|
class Railtie
|
|
15
5
|
def self.insert
|
|
16
6
|
ActiveRecord::Base.include(ValidatesLengthsFromDatabase)
|
|
17
7
|
end
|
|
18
8
|
end
|
|
19
9
|
end
|
|
20
|
-
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
require "active_support"
|
|
2
2
|
require "active_support/i18n"
|
|
3
|
+
require "active_model"
|
|
3
4
|
|
|
4
5
|
I18n.load_path << File.expand_path("../config/locales/en.yml", __dir__)
|
|
5
6
|
|
|
6
7
|
require "validates_lengths_from_database/core"
|
|
7
8
|
require "validates_lengths_from_database/railtie"
|
|
9
|
+
|
|
10
|
+
# Runs as soon as ActiveRecord::Base loads, or right away if it already has,
|
|
11
|
+
# so the gem works with or without Rails and regardless of require order.
|
|
12
|
+
ActiveSupport.on_load(:active_record) do
|
|
13
|
+
include ValidatesLengthsFromDatabase
|
|
14
|
+
end
|