Skip to content

Commit

Permalink
Refactor methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
tinaafitz committed Feb 2, 2017
1 parent 755c853 commit bb24ca7
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,30 @@ def initialize(handle = $evm)

def main
@handle.log("info", "Starting check_completed")

task = @handle.root["service_template_provision_task"]
service = task.try(:destination)

unless service
@handle.log(:error, 'Service is nil')
raise 'Service is nil'
end

check_completed(service)
@handle.log("info", "Ending check_completed")
end

private

def task
@handle.root["service_template_provision_task"].tap do |task|
if task.nil?
@handle.log(:error, 'service_template_provision_task is nil')
raise "service_template_provision_task not found"
end
end
end

def service
task.destination.tap do |service|
if service.nil?
@handle.log(:error, 'Service is nil')
raise 'Service not found'
end
end
end

def check_completed(service)
done, message = service.check_completed(@handle.root["service_action"])
if done
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,31 @@ def initialize(handle = $evm)
end

def main
task = @handle.root["service_template_provision_task"]
service = task.try(:destination)

unless service
@handle.log(:error, 'Service is nil')
raise 'Service is nil'
end

@handle.log("info", "Starting Check Refreshed")
check_refreshed(service)
@handle.log("info", "Ending Check Refreshed")
end

private

def task
@handle.root["service_template_provision_task"].tap do |task|
if task.nil?
@handle.log(:error, 'service_template_provision_task is nil')
raise "service_template_provision_task not found"
end
end
end

def service
task.destination.tap do |service|
if service.nil?
@handle.log(:error, 'Service is nil')
raise 'Service not found'
end
end
end

def check_refreshed(service)
done, message = service.check_refreshed(@handle.root['service_action'])
if done
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ def initialize(handle = $evm)
def main
@handle.log("info", "Starting execute")

task = @handle.root["service_template_provision_task"]
service = task.destination

begin
service.execute(@handle.root["service_action"])
@handle.log("info", "Ending execute")
Expand All @@ -28,6 +25,26 @@ def main
@handle.log("info", "Error in execute")
end
end

private

def task
@handle.root["service_template_provision_task"].tap do |task|
if task.nil?
@handle.log(:error, 'service_template_provision_task is nil')
raise "service_template_provision_task not found"
end
end
end

def service
task.destination.tap do |service|
if service.nil?
@handle.log(:error, 'Service is nil')
raise 'Service not found'
end
end
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,29 @@ def initialize(handle = $evm)

def main
@handle.log("info", "Starting PostProcessing")

task = @handle.root["service_template_provision_task"]
service = task.destination

service.postprocess(@handle.root["service_action"])
@handle.log("info", "Ending PostProcessing")
end

private

def task
@handle.root["service_template_provision_task"].tap do |task|
if task.nil?
@handle.log(:error, 'service_template_provision_task is nil')
raise "service_template_provision_task not found"
end
end
end

def service
task.destination.tap do |service|
if service.nil?
@handle.log(:error, 'Service is nil')
raise 'Service not found'
end
end
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,37 @@ def initialize(handle = $evm)

def main
@handle.log("info", "Starting preprocess")
dump_root
options = {}
# user can insert options to override options from dialog
service.preprocess(@handle.root["service_action"], options)
end

private

def dump_root
@handle.log("info", "Root:<$evm.root> Attributes - Begin")
@handle.root.attributes.sort.each { |k, v| $evm.log("info", " Attribute - #{k}: #{v}") }
@handle.log("info", "Root:<$evm.root> Attributes - End")
@handle.log("info", "")
end

def task
@handle.root["service_template_provision_task"].tap do |task|
if task.nil?
@handle.log(:error, 'service_template_provision_task is nil')
raise "service_template_provision_task not found"
end
end
end

service = @handle.root["service_template_provision_task"].try(:destination)
unless service
@handle.log(:error, 'Service is nil')
raise 'Service is nil'
def service
task.destination.tap do |service|
if service.nil?
@handle.log(:error, 'Service is nil')
raise 'Service not found'
end
end
options = {}
# user can insert options to override options from dialog
service.preprocess(@handle.root["service_action"], options)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,30 @@ def initialize(handle = $evm)
end

def main
task = @handle.root["service_template_provision_task"]
service = task.try(:destination)

unless service
@handle.log(:error, 'Service is nil')
raise 'Service is nil'
end

@handle.log("info", "Starting Refresh")
service.refresh(@handle.root["service_action"])
@handle.log("info", "Ending Refresh")
end

private

def task
@handle.root["service_template_provision_task"].tap do |task|
if task.nil?
@handle.log(:error, 'service_template_provision_task is nil')
raise "service_template_provision_task not found"
end
end
end

def service
task.destination.tap do |service|
if service.nil?
@handle.log(:error, 'Service is nil')
raise 'Service not found'
end
end
end
end
end
end
Expand Down

0 comments on commit bb24ca7

Please sign in to comment.