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

#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

#invalidate_target_methodsObject



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

def invalidate_target_methods
  context[:target_methods] = nil
end

#invalidate_target_metricsObject



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

def invalidate_target_metrics
  context[:target_metrics] = nil
end

#option_target_system_nameObject



92
93
94
# File 'lib/3scale_toolbox/commands/service_command/copy_command/task.rb', line 92

def option_target_system_name
  context[:option_target_system_name]
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_hitsObject



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

def source_hits
  context[:source_hits] ||= source.hits
end

#source_methodsObject



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

def source_methods
  context[:source_methods] ||= source.methods(source_hits.fetch('id'))
end

#source_metricsObject



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

def source_metrics
  context[:source_metrics] ||= source.metrics
end

#source_metrics_and_methodsObject



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

def source_metrics_and_methods
  source_metrics + source_methods
end

#source_remoteObject



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

def source_remote
  context[:source_remote]
end

#source_service_refObject



87
88
89
90
# File 'lib/3scale_toolbox/commands/service_command/copy_command/task.rb', line 87

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_hitsObject



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

def target_hits
  context[:target_hits] ||= target.hits
end

#target_methodsObject



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

def target_methods
  context[:target_methods] ||= target.methods(target_hits.fetch('id'))
end

#target_metricsObject



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

def target_metrics
  context[:target_metrics] ||= target.metrics
end

#target_metrics_and_methodsObject



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

def target_metrics_and_methods
  target_metrics + target_methods
end

#target_remoteObject



83
84
85
# File 'lib/3scale_toolbox/commands/service_command/copy_command/task.rb', line 83

def target_remote
  context[:target_remote]
end