require 'yaml' require 'active_resource' class ServiceLocator API_KEY = "kittens" def self.services return @services if @services config_file = File.join(Rails.root.to_s, %w[config services.yml]) config = YAML.load_file(config_file) @services = config[Rails.env] end def self.[](name) "#{services[name.to_s]}" end end def Service(name) Class.new(ActiveResource::Base) do self.site = "#{ServiceLocator[name]}" self.user = "amberleaf" self.password = "includes1" self.timeout = 30 end end