Class: Envvar::Railtie
- Inherits:
-
Rails::Railtie
- Object
- Rails::Railtie
- Envvar::Railtie
- Defined in:
- lib/envvar/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_missing` to delegate all class methods to the instance, which means `Kernel#load` gets called here.
Instance Method Summary collapse
-
#load ⇒ Object
Public: Load dotenv.
-
#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.
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.
41 42 43 |
# File 'lib/envvar/rails.rb', line 41 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.
28 29 30 |
# File 'lib/envvar/rails.rb', line 28 def load Envvar.load(config_file, Rails.env) 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.
35 36 37 |
# File 'lib/envvar/rails.rb', line 35 def root Rails.root || Pathname.new(ENV['RAILS_ROOT'] || Dir.pwd) end |