Module: ThreeScaleToolbox::Commands::ServiceCommand::CopyCommand::Task

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



6
7
8
# File 'lib/3scale_toolbox/commands/service_command/copy_command/task.rb', line 6

def context
  @context
end

Instance Method Details

#activedocs_reportObject



74
75
76
# File 'lib/3scale_toolbox/commands/service_command/copy_command/task.rb', line 74

def activedocs_report
  report['activedocs'] ||= {}
end

#delete_mapping_rulesObject



31
32
33
# File 'lib/3scale_toolbox/commands/service_command/copy_command/task.rb', line 31

def delete_mapping_rules
  context.fetch(:delete_mapping_rules, false)
end

#find_source_serviceObject



16
17
18
19
20
# File 'lib/3scale_toolbox/commands/service_command/copy_command/task.rb', line 16

def find_source_service
  Entities::Service.find(remote: source_remote, ref: source_service_ref).tap do |svc|
    raise ThreeScaleToolbox::Error, "Service #{source_service_ref} does not exist" if svc.nil?
  end
end

#force_delete_mapping_rulesObject



35
36
37
# File 'lib/3scale_toolbox/commands/service_command/copy_command/task.rb', line 35

def force_delete_mapping_rules
  context[:delete_mapping_rules] = true
end

#initialize(context) ⇒ Object



8
9
10
# File 'lib/3scale_toolbox/commands/service_command/copy_command/task.rb', line 8

def initialize(context)
  @context = context
end

#loggerObject



64
65
66
67
68
# File 'lib/3scale_toolbox/commands/service_command/copy_command/task.rb', line 64

def logger
  context[:logger] ||= Logger.new($stdout).tap do |logger|
    logger.formatter = proc { |severity, datetime, progname, msg| "#{msg}\n" }
  end
end

#option_target_system_nameObject



60
61
62
# File 'lib/3scale_toolbox/commands/service_command/copy_command/task.rb', line 60

def option_target_system_name
  context[:option_target_system_name]
end

#plans_reportObject



70
71
72
# File 'lib/3scale_toolbox/commands/service_command/copy_command/task.rb', line 70

def plans_report
  report['application_plans'] ||= {}
end

#reportObject



78
79
80
# File 'lib/3scale_toolbox/commands/service_command/copy_command/task.rb', line 78

def report
  context[:report] ||= {}
end

#sourceObject



12
13
14
# File 'lib/3scale_toolbox/commands/service_command/copy_command/task.rb', line 12

def source
  context[:source] ||= find_source_service
end

#source_metrics_and_methodsObject



39
40
41
# File 'lib/3scale_toolbox/commands/service_command/copy_command/task.rb', line 39

def source_metrics_and_methods
  source.metrics + source.methods
end

#source_remoteObject



47
48
49
# File 'lib/3scale_toolbox/commands/service_command/copy_command/task.rb', line 47

def source_remote
  context[:source_remote]
end

#source_service_refObject



55
56
57
58
# File 'lib/3scale_toolbox/commands/service_command/copy_command/task.rb', line 55

def source_service_ref
  context[:source_service_ref] ||= raise ThreeScaleToolbox::Error, 'Unexpected error. ' \
    'source_service_ref not found'
end

#targetObject



22
23
24
25
# File 'lib/3scale_toolbox/commands/service_command/copy_command/task.rb', line 22

def target
  context[:target] ||= raise ThreeScaleToolbox::Error, 'Unexpected error. ' \
    'Target service should have been created or updated'
end

#target=(target) ⇒ Object



27
28
29
# File 'lib/3scale_toolbox/commands/service_command/copy_command/task.rb', line 27

def target=(target)
  context[:target] = target
end

#target_metrics_and_methodsObject



43
44
45
# File 'lib/3scale_toolbox/commands/service_command/copy_command/task.rb', line 43

def target_metrics_and_methods
  target.metrics + target.methods
end

#target_remoteObject



51
52
53
# File 'lib/3scale_toolbox/commands/service_command/copy_command/task.rb', line 51

def target_remote
  context[:target_remote]
end