Check to see if being run in Rails application and run in before_initialize#555
Conversation
before_initialize
lib/split.rb
Outdated
|
|
||
| Split.configure {} | ||
| # Check to see if being run in a Rails application. If so, wait until before_initialize to run configuration so Gems that create ENV variables have the chance to initialize first. | ||
| if defined?(Rails::Railtie) |
There was a problem hiding this comment.
Can you change this to check for Rails instead?
if defined?(::Rails)See other gems for example: https://github.com/mperham/sidekiq/blob/master/lib/sidekiq/rails.rb#L51 and https://github.com/brandonhilkert/sucker_punch/blob/master/lib/sucker_punch.rb#L57
There was a problem hiding this comment.
Sure thing! I thought being explicit (since we will be inheriting from Railties) was better, but seeing the convention of checking for ::Rails seems like a good idea. Updated!
|
Thanks for the PR @husteadrobert! I left a small comment, after that I'll merge it :) |
|
I don't seem to be able to re-request a review, so I'm leaving a comment here. If you need any other changes, please let me know! @andrehjr |
|
Thanks @husteadrobert with this PR, it should be possible to use Figaro :) |
Addresses isssue #528
Checks to see if Rails::Railtie is defined, and if so sets the Railtie to run before_initialize. I've run this locally with no issues and specs are passing.