Last active
August 29, 2015 14:10
-
-
Save perryqh/823e7dba52175712b53c to your computer and use it in GitHub Desktop.
InstantiateConfig - by strategy_type
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class InstantiateConfig | |
def self.execute(lead_params={}) | |
location_uid = lead_params.try(:[], :location_uid) | |
strategy_type = lead_params.try(:[], :strategy_type) | |
if integration_settings = integration_settings_for(location_uid, strategy_type) | |
integration_settings_hash = integration_settings.properties | |
config_params = integration_settings_hash.merge(lead_params) | |
config_params[:integration_settings] = integration_settings_hash | |
end | |
config_params ||= lead_params | |
LeadConfig.new(config_params) | |
end | |
private | |
# getting LocationSetting by strategy_type and location_uit | |
def self.integration_settings_for(location_uid, strategy_type) | |
G5IntegrationsUpdatable::LocationSetting.by_strategy_type(strategy_type).find_by_location_uid(location_uid) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment