Module: ThreeScaleToolbox::Commands::ServiceCommand::CopyCommand::Task
- Included in:
- CopyActiveDocsTask, CopyApplicationPlansTask, CopyLimitsTask, CopyMappingRulesTask, CopyMethodsTask, CopyMetricsTask, CopyPoliciesTask, CopyPricingRulesTask, CopyServiceProxyTask, CreateOrUpdateTargetServiceTask
- Defined in:
- lib/3scale_toolbox/commands/service_command/copy_command/task.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
- #delete_mapping_rules ⇒ Object
- #find_source_service ⇒ Object
- #force_delete_mapping_rules ⇒ Object
- #initialize(context) ⇒ Object
- #invalidate_target_methods ⇒ Object
- #invalidate_target_metrics ⇒ Object
- #option_target_system_name ⇒ Object
- #source ⇒ Object
- #source_hits ⇒ Object
- #source_methods ⇒ Object
- #source_metrics ⇒ Object
- #source_metrics_and_methods ⇒ Object
- #source_remote ⇒ Object
- #source_service_ref ⇒ Object
- #target ⇒ Object
- #target=(target) ⇒ Object
- #target_hits ⇒ Object
- #target_methods ⇒ Object
- #target_metrics ⇒ Object
- #target_metrics_and_methods ⇒ Object
- #target_remote ⇒ Object
Instance Attribute Details
#context ⇒ Object (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_rules ⇒ Object
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_service ⇒ Object
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_rules ⇒ Object
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_methods ⇒ Object
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_metrics ⇒ Object
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_name ⇒ Object
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 |
#source ⇒ Object
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_hits ⇒ Object
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_methods ⇒ Object
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_metrics ⇒ Object
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_methods ⇒ Object
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_remote ⇒ Object
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_ref ⇒ Object
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 |
#target ⇒ Object
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_hits ⇒ Object
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_methods ⇒ Object
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_metrics ⇒ Object
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_methods ⇒ Object
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_remote ⇒ Object
83 84 85 |
# File 'lib/3scale_toolbox/commands/service_command/copy_command/task.rb', line 83 def target_remote context[:target_remote] end |