Module: LeapSalesforce::Loader
- Defined in:
- lib/leap_salesforce/loader.rb
Overview
For loading dependent code based on configuration
Constant Summary collapse
- LEAP_CONFIG_FILE =
Returns Location of leap_salesforce YAML file.
'.leap_salesforce.yml'
Class Method Summary collapse
-
.load_config_file ⇒ Object
Load configuration file and set properties based on it.
-
.set_leaps_property(key, value) ⇒ Object
Set LeapSalesforce property if it exists.
Class Method Details
.load_config_file ⇒ Object
Load configuration file and set properties based on it
23 24 25 26 27 28 29 30 31 |
# File 'lib/leap_salesforce/loader.rb', line 23 def load_config_file if File.exist? LEAP_CONFIG_FILE leap_config = YAML.load_file LEAP_CONFIG_FILE LeapSalesforce.soql_objects = leap_config.delete('soql_objects') leap_config.each { |key, value| set_leaps_property(key, value) } else LeapSalesforce.logger.warn "No config file found at '#{LEAP_CONFIG_FILE}' for Leap Salesforce" end end |
.set_leaps_property(key, value) ⇒ Object
Set LeapSalesforce property if it exists
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/leap_salesforce/loader.rb', line 10 def set_leaps_property(key, value) if LeapSalesforce.respond_to? "#{key}=" if %w[SF_CONSUMER_KEY client_id client_secret password].include? key LeapSalesforce.logger.warn "Secret key '#{key}' should be in non version" \ " controlled #{LeapSalesforce::CREDENTIAL_FILE} not in #{LEAP_CONFIG_FILE}" end LeapSalesforce.send("#{key}=", value) else LeapSalesforce.logger.warn "No property for '#{key}' from '#{LEAP_CONFIG_FILE}'" end end |