class Masheri::Config
Constants
- DEFAULT_HOSTS
Attributes
config[RW]
Public Class Methods
new(yaml_file)
click to toggle source
# File lib/masheri/config.rb, line 10 def initialize(yaml_file) @config ||= YAML.load_file(yaml_file) check_config! end
Public Instance Methods
check_config!()
click to toggle source
# File lib/masheri/config.rb, line 15 def check_config! if config["site_id"].blank? raise ParamMissing.new("site_id") end if config["key"].blank? raise ParamMissing.new("key") end if config["secret"].blank? raise ParamMissing.new("secret") end find_host! end
host()
click to toggle source
# File lib/masheri/config.rb, line 45 def host @host ||= find_host! end
key()
click to toggle source
# File lib/masheri/config.rb, line 35 def key @key ||= config["key"] end
Also aliased as: api_key
secret()
click to toggle source
# File lib/masheri/config.rb, line 41 def secret @secret ||= config["secret"] end
signature()
click to toggle source
# File lib/masheri/config.rb, line 49 def signature Digest::MD5.hexdigest(key + secret + Time.now.to_f.to_i.to_s) end
site_id()
click to toggle source
# File lib/masheri/config.rb, line 31 def site_id @site_id ||= config["site_id"] end
Protected Instance Methods
find_host!()
click to toggle source
# File lib/masheri/config.rb, line 55 def find_host! if config["host"].present? config["host"] else if defined?(Rails) if Rails.env.test? || Rails.env.development? DEFAULT_HOSTS[:test] elsif Rails.env.production? DEFAULT_HOSTS[:production] end end raise ParamMissing.new("host") end end