Created
December 14, 2016 09:53
-
-
Save d1ys3nk0/c273adee8010bb4b2bbfdc487e2bbe3e to your computer and use it in GitHub Desktop.
App Class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Environment | |
def self.values | |
%w(debug development test staging production) | |
end | |
values.each do |env| | |
class_eval %Q{ | |
def #{env}? | |
@env == :#{env} | |
end | |
} | |
end | |
def initialize | |
env = ENV.fetch('ENV', 'development').downcase.to_sym | |
fail 'Unknown env setting' unless self.class.values.include?(env.to_s) | |
@env = env.to_sym | |
end | |
def to_s | |
@env.to_s | |
end | |
def to_sym | |
@env.to_sym | |
end | |
end | |
class App | |
@@env = Environment.new | |
def self.version | |
'1.13.0' | |
end | |
def self.env | |
@@env | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.