Created
March 31, 2015 15:48
-
-
Save jordanhudgens/d5fd934fffd8e8e307c4 to your computer and use it in GitHub Desktop.
This file contains 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 DomainConfig | |
def initialize(config) | |
@config = config | |
end | |
def hosta | |
return @config["host"][Rails.env] || 'example1.dev' | |
end | |
def name | |
return @config["name"] | |
end | |
def folder | |
return @config["folder"] | |
end | |
def welcome_email_from_email | |
return @config["welcome_email_from_email"][Rails.env] | |
end | |
def admin_training_thank_you_email | |
return @config["admin_training_thank_you_email"] | |
end | |
def training_thank_you_email | |
return @config["training_thank_you_email"] | |
end | |
def single_user_video | |
return @config['single_user_video'] | |
end | |
def self.email_spoof(site) | |
if site == "example1" | |
return "admin@example1.com" | |
elsif site == "example2" | |
return "admin@example2.com" | |
else | |
return "admin@example1.com" | |
end | |
end | |
def self.from_host(host) | |
domain = DomainName(host).domain | |
DOMAIN_CONFIG.each_pair do | site, config | | |
if config["host"][Rails.env].include? domain | |
return DomainConfig.new(config) | |
end | |
end | |
if Rails.env.test? | |
return DomainConfig.from_host('example1.dev') | |
end | |
raise "domain config was not found for #{Rails.env} environment on domain #{host}" | |
end | |
def self.from_site_name(site) | |
config = DomainConfig.new( DOMAIN_CONFIG[site] ) | |
raise "domain config was not found for site name #{site}" if config.nil? | |
return config | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment