diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2017-06-21 15:39:05 +0300 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2017-06-21 15:39:05 +0300 |
commit | 2a7f1eec12657310e2f8a24b0a1f0a659b9363d6 (patch) | |
tree | fa0dd3a8fbf875e9ada0a94193515521adbde81a /app/services/create_deployment_service.rb | |
parent | 98b60ee29ba99ec28f4c4782a76f52d675eaf083 (diff) |
Memorize the value in methods rather than local
Diffstat (limited to 'app/services/create_deployment_service.rb')
-rw-r--r-- | app/services/create_deployment_service.rb | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/app/services/create_deployment_service.rb b/app/services/create_deployment_service.rb index 45f68391df8..63b85c3de7d 100644 --- a/app/services/create_deployment_service.rb +++ b/app/services/create_deployment_service.rb @@ -14,10 +14,8 @@ class CreateDeploymentService return unless executable? ActiveRecord::Base.transaction do - if external_url = expanded_environment_url - environment.external_url = external_url - end - + environment.external_url = expanded_environment_url if + expanded_environment_url environment.fire_state_event(action) return unless environment.save @@ -53,8 +51,14 @@ class CreateDeploymentService end def expanded_environment_url - ExpandVariables.expand(environment_options[:url], variables) if - environment_options[:url] + return @expanded_environment_url if defined?(@expanded_environment_url) + + @expanded_environment_url = + ExpandVariables.expand(environment_url, variables) if environment_url + end + + def environment_url + environment_options[:url] end def on_stop |