summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorCallum Dryden <callum.dryden@rightscale.com>2017-02-16 09:48:29 +0000
committerCallum Dryden <callum.dryden@rightscale.com>2017-02-16 13:41:29 +0000
commita2c94aa6de8b6743488e9dba3693c847ad2b1bcd (patch)
tree9ed2fd247759fd774033c07d7734378e2fe35dc1 /lib
parent439bb066feb05403c7843fb6af65b83b453a0fd8 (diff)
downloadhashie-a2c94aa6de8b6743488e9dba3693c847ad2b1bcd.tar.gz
Ensure Railties available when loading Railtie
In some circumstances when a project has the Rails constant defined we may still not be able to require the rails/railtie dependency. Before this change this would raise an exception. This change seeks to add better detection of the railtie dependency and add logging that this dependency is missing but still allow execution to continue.
Diffstat (limited to 'lib')
-rw-r--r--lib/hashie/railtie.rb16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/hashie/railtie.rb b/lib/hashie/railtie.rb
index f69a13f..65cd007 100644
--- a/lib/hashie/railtie.rb
+++ b/lib/hashie/railtie.rb
@@ -1,10 +1,14 @@
-require 'rails/railtie'
+begin
+ require 'rails/railtie'
-module Hashie
- class Railtie < Rails::Railtie
- # Set the Hashie.logger to use Rails.logger when used with rails.
- initializer 'hashie.configure_logger', after: 'initialize_logger' do
- Hashie.logger = Rails.logger
+ module Hashie
+ class Railtie < Rails::Railtie
+ # Set the Hashie.logger to use Rails.logger when used with rails.
+ initializer 'hashie.configure_logger', after: 'initialize_logger' do
+ Hashie.logger = Rails.logger
+ end
end
end
+rescue LoadError => e
+ Hashie.logger.info("Hashie skipping railtie as #{e.message}")
end