Class: Dotenv::Railtie
- Inherits:
-
Rails::Railtie
- Object
- Rails::Railtie
- Dotenv::Railtie
- Defined in:
- lib/dotenv/rails.rb
Overview
Dotenv Railtie for using Dotenv to load environment from a file into Rails applications
Class Method Summary collapse
-
.load ⇒ Object
Rails uses
#method_missingto delegate all class methods to the instance, which means ‘Kernel#load` gets called here.
Instance Method Summary collapse
-
#load ⇒ Object
Public: Load dotenv.
-
#overload ⇒ Object
Public: Reload dotenv.
-
#root ⇒ Object
Internal:
Rails.rootis nil in Rails 4.1 before the application is initialized, so this falls back to theRAILS_ROOTenvironment variable, or the current working directory.
Class Method Details
.load ⇒ Object
Rails uses #method_missing to delegate all class methods to the instance, which means ‘Kernel#load` gets called here. We don’t want that.
60 61 62 |
# File 'lib/dotenv/rails.rb', line 60 def self.load instance.load end |
Instance Method Details
#load ⇒ Object
Public: Load dotenv
This will get called during the before_configuration callback, but you can manually call Dotenv::Railtie.load if you needed it sooner.
40 41 42 |
# File 'lib/dotenv/rails.rb', line 40 def load Dotenv.load(*dotenv_files) end |
#overload ⇒ Object
Public: Reload dotenv
Same as load, but will override existing values in ENV
47 48 49 |
# File 'lib/dotenv/rails.rb', line 47 def overload Dotenv.overload(*dotenv_files) end |
#root ⇒ Object
Internal: Rails.root is nil in Rails 4.1 before the application is initialized, so this falls back to the RAILS_ROOT environment variable, or the current working directory.
54 55 56 |
# File 'lib/dotenv/rails.rb', line 54 def root Rails.root || Pathname.new(ENV["RAILS_ROOT"] || Dir.pwd) end |