Skip to content

Commit

Permalink
Fix autoloading the VERSION constant
Browse files Browse the repository at this point in the history
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 `<main>': 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 `<top (required)>'
        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 `<main>'
```

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).
  • Loading branch information
skipkayhil committed Jan 4, 2024
1 parent bb28d45 commit d52af9a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/statesman.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit d52af9a

Please sign in to comment.