From d52af9a4778a80a947908045a412d99f0bf86c33 Mon Sep 17 00:00:00 2001 From: Hartley McGuire Date: Thu, 4 Jan 2024 15:45:55 -0500 Subject: [PATCH] Fix autoloading the VERSION constant While waiting for Statesman to support gap lock protection for Trilogy by default, I wanted to add a conditional monkeypatch to my Rails app based on the version of Statesman loaded. However, trying to reference `Statesman::VERSION` leads to an error: ``` $ irb irb(main):001> require "statesman" => true irb(main):002> Statesman::VERSION (irb):2:in `
': uninitialized constant Statesman::VERSION (NameError) Did you mean? Statesman::Version from /home/hartley/.cache/asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.11.0/exe/irb:9:in `' from /home/hartley/.cache/asdf/installs/ruby/3.2.2/bin/irb:25:in `load' from /home/hartley/.cache/asdf/installs/ruby/3.2.2/bin/irb:25:in `
' ``` This commit fixes the issue by changing the autoload for the `version.rb` file to point to `VERSION` instead of `Version` (which does not exist). --- lib/statesman.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/statesman.rb b/lib/statesman.rb index 57b7821c..cf9fe346 100644 --- a/lib/statesman.rb +++ b/lib/statesman.rb @@ -6,7 +6,7 @@ module Statesman autoload :Callback, "statesman/callback" autoload :Guard, "statesman/guard" autoload :Utils, "statesman/utils" - autoload :Version, "statesman/version" + autoload :VERSION, "statesman/version" module Adapters autoload :Memory, "statesman/adapters/memory" autoload :ActiveRecord, "statesman/adapters/active_record"