Class: Formidable::Config
- Inherits:
-
Object
- Object
- Formidable::Config
- Defined in:
- lib/formidable/config.rb
Constant Summary collapse
- DEFAULTS =
{ :api_key => "", :use_ssl => false, :track_values => false, :thread => true }
Class Attribute Summary collapse
-
.api_key ⇒ Object
Returns the value of attribute api_key.
-
.thread ⇒ Object
Returns the value of attribute thread.
-
.track_values ⇒ Object
Returns the value of attribute track_values.
-
.use_ssl ⇒ Object
Returns the value of attribute use_ssl.
Class Method Summary collapse
Class Attribute Details
.api_key ⇒ Object
Returns the value of attribute api_key.
14 15 16 |
# File 'lib/formidable/config.rb', line 14 def api_key @api_key end |
.thread ⇒ Object
Returns the value of attribute thread.
14 15 16 |
# File 'lib/formidable/config.rb', line 14 def thread @thread end |
.track_values ⇒ Object
Returns the value of attribute track_values.
14 15 16 |
# File 'lib/formidable/config.rb', line 14 def track_values @track_values end |
.use_ssl ⇒ Object
Returns the value of attribute use_ssl.
14 15 16 |
# File 'lib/formidable/config.rb', line 14 def use_ssl @use_ssl end |
Class Method Details
.load(settings) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/formidable/config.rb', line 27 def load(settings) # symbolize keys settings = settings.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} # ensure we have default settings settings = DEFAULTS.merge(settings) [:api_key, :use_ssl, :track_values, :thread].each do |setting| self.send("#{setting}=", settings[setting]) end end |
.load_file(config_file) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/formidable/config.rb', line 16 def load_file(config_file) begin config = YAML::load_file(config_file) env_config = config[app_env] || {} settings = config.merge(env_config) load(settings) rescue Exception => e raise "Configuration error: #{e.}" end end |