Class: Envyable::Railtie

Inherits:
Rails::Railtie
  • Object
show all
Defined in:
lib/envyable/railtie.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.loadObject

Avoid Rails calling ‘Kernel#load` via #method_mising



20
21
22
# File 'lib/envyable/railtie.rb', line 20

def self.load
  instance.load
end

Instance Method Details

#loadObject



9
10
11
# File 'lib/envyable/railtie.rb', line 9

def load
  Envyable.load root.join('config', 'env.yml'), Rails.env
end

#rootObject

Fallback of ENV variable or current directory because Rails 4.1+ returns nil for Rails.root prior to app initialization



15
16
17
# File 'lib/envyable/railtie.rb', line 15

def root
  Rails.root || Pathname.new(ENV["RAILS_ROOT"] || Dir.pwd)
end