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: 5cf4553c64ac4dd1b06fce9e8b6123f3bb426a7a83d0e8ee4949db2ae530aa76
4
- data.tar.gz: b714ddd62d656a23029b181448e7d6881542c3da7b3b1988ff63e4153b7e43dc
3
+ metadata.gz: b858050297bdf446939c8671bc1b2260345e6bc223762cb0a533264e8dce2b1a
4
+ data.tar.gz: a5f5f3f169cb2919f1bedd7baa548cebb4a75730ca953280636e4f1fa3058a73
5
5
  SHA512:
6
- metadata.gz: 381df3fa482b0f1d882ac8d81b35282db35a8d66cfe523c9f9f6a9ebbb6234d2319a1fa3264f06bc36e2c5fafc3e022dce53091350fff5bfa231e73d440da9e5
7
- data.tar.gz: 896b9a14a0104a7723a7bc026d3fc5479ca8c0d5128a6107064ec08314bc08c60485c5bac8b2e334cb4dae10ac0fe3b96391732c877bb6e1cfae9535b8111f26
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
- if defined?(Rails::Railtie)
3
- require "rails"
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,3 +1,3 @@
1
1
  module ValidatesLengthsFromDatabase
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validates_lengths_from_database
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Hughes