Module: Mongoid::Config::Environment
Overview
Encapsulates logic for getting environment information.
Instance Method Summary collapse
-
#env_name ⇒ String
Get the name of the environment that we are running under.
-
#load_yaml(path) ⇒ Hash
Load the yaml from the provided path and return the settings for the current environment.
Instance Method Details
#env_name ⇒ String
Get the name of the environment that we are running under. This first looks for Rails, then Sinatra, then a RACK_ENV environment variable, and if none of those are found returns “development”.
19 20 21 22 23 |
# File 'lib/mongoid/config/environment.rb', line 19 def env_name return Rails.env if defined?(Rails) return Sinatra::Base.environment.to_s if defined?(Sinatra) ENV["RACK_ENV"] || ENV["MONGOID_ENV"] || raise(Errors::NoEnvironment.new) end |
#load_yaml(path) ⇒ Hash
Load the yaml from the provided path and return the settings for the current environment.
36 37 38 |
# File 'lib/mongoid/config/environment.rb', line 36 def load_yaml(path) YAML.load(ERB.new(File.new(path).read).result)[env_name] end |