Sha256: fd99950b1accbca246404b4ce714817baa57fba85cdc579023a1bd5cb57febe3
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 KB
Contents
module Ym4r module GmPlugin class GMapsAPIKeyConfigFileNotFoundException < StandardError end class AmbiguousGMapsAPIKeyException < StandardError end #Class fo the manipulation of the API key class ApiKey #Read the API key config for the current ENV unless File.exist?(Rails.root.join("config","gmaps_api_key.yml")) raise GMapsAPIKeyConfigFileNotFoundException.new("File config/gmaps_api_key.yml not found") else env = ENV['RAILS_ENV'] || Rails.env GMAPS_API_KEY = YAML.load_file(Rails.root.join("config","gmaps_api_key.yml"))[env] end def self.get(options = {}) if options.has_key?(:key) options[:key] elsif GMAPS_API_KEY.is_a?(Hash) #For this environment, multiple hosts are possible. #:host must have been passed as option if options.has_key?(:host) GMAPS_API_KEY[options[:host]] else raise AmbiguousGMapsAPIKeyException.new(GMAPS_API_KEY.keys.join(",")) end else #Only one possible key: take it and ignore the :host option if it is there GMAPS_API_KEY end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ym4r_gm-0.2.0 | lib/gm_plugin/key.rb |