Commit 2a7f1eec authored by Lin Jen-Shin's avatar Lin Jen-Shin

Memorize the value in methods rather than local

parent 98b60ee2
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment