Class: Mashery::Config
- Inherits:
-
Object
- Object
- Mashery::Config
- Defined in:
- lib/mashery/config.rb
Constant Summary collapse
- DEFAULT_HOSTS =
{ test: 'api.sandbox.mashery.com', production: 'api.mashery.com' }
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
Instance Method Summary collapse
- #check_config! ⇒ Object
- #host ⇒ Object
-
#initialize(yaml_file) ⇒ Config
constructor
A new instance of Config.
- #key ⇒ Object (also: #api_key)
- #secret ⇒ Object
- #signature ⇒ Object
- #site_id ⇒ Object
Constructor Details
#initialize(yaml_file) ⇒ Config
Returns a new instance of Config.
10 11 12 13 |
# File 'lib/mashery/config.rb', line 10 def initialize(yaml_file) @config ||= YAML.load_file(yaml_file) check_config! end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
8 9 10 |
# File 'lib/mashery/config.rb', line 8 def config @config end |
Instance Method Details
#check_config! ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/mashery/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 ⇒ Object
45 46 47 |
# File 'lib/mashery/config.rb', line 45 def host @host ||= find_host! end |
#key ⇒ Object Also known as: api_key
35 36 37 |
# File 'lib/mashery/config.rb', line 35 def key @key ||= config["key"] end |
#secret ⇒ Object
41 42 43 |
# File 'lib/mashery/config.rb', line 41 def secret @secret ||= config["secret"] end |
#signature ⇒ Object
49 50 51 |
# File 'lib/mashery/config.rb', line 49 def signature Digest::MD5.hexdigest(key + secret + Time.now.to_f.to_i.to_s) end |
#site_id ⇒ Object
31 32 33 |
# File 'lib/mashery/config.rb', line 31 def site_id @site_id ||= config["site_id"] end |