mgomes / api_auth

HMAC authentication for Rails and HTTP Clients
MIT License
480 stars 147 forks source link

Check for ActiveSupport presence in railtie definition #189

Closed taylorthurlow closed 4 years ago

taylorthurlow commented 4 years ago

This PR is related to the accidental introduction of an ActiveSupport dependency into the gem. api_auth should be able to be used without Rails (and therefore without ActiveSupport). Because the railtie is always included when the gem is loaded, the railtie is loaded even when Rails is not.

This was not historically an issue because before the merging of my pull request to fix a related deprecation warning, we checked for the definition of ActiveController::Base, which meant that the railtie file could be required even if Rails was not.

Because the definition check was the source of the deprecation warning that I fixed in my original PR, my change had the effect of breaking the railtie inclusion if ActiveSupport is not bundled.

This PR solves the issue by checking for the definition of ActiveSupport before using the on_load hooks. An alternative solution (which might make more sense) would be to conditionally include the railtie in its entirety here:

# ...
require 'api_auth/railtie' if defined?(::Rails)

Let me know what you think about how this problem should be solved.

fwininger commented 4 years ago

👍

mgomes commented 4 years ago

Thanks for the follow up PR @taylorthurlow. 👍