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
- #activedocs_report ⇒ Object
- #delete_mapping_rules ⇒ Object
- #find_source_service ⇒ Object
- #force_delete_mapping_rules ⇒ Object
- #initialize(context) ⇒ Object
- #logger ⇒ Object
- #option_target_system_name ⇒ Object
- #plans_report ⇒ Object
- #report ⇒ Object
- #source ⇒ Object
- #source_metrics_and_methods ⇒ Object
- #source_remote ⇒ Object
- #source_service_ref ⇒ Object
- #target ⇒ Object
- #target=(target) ⇒ 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
#activedocs_report ⇒ Object
74 75 76 |
# File 'lib/3scale_toolbox/commands/service_command/copy_command/task.rb', line 74 def activedocs_report report['activedocs'] ||= {} end |
#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 |
#logger ⇒ Object
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_name ⇒ Object
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_report ⇒ Object
70 71 72 |
# File 'lib/3scale_toolbox/commands/service_command/copy_command/task.rb', line 70 def plans_report report['application_plans'] ||= {} end |
#report ⇒ Object
78 79 80 |
# File 'lib/3scale_toolbox/commands/service_command/copy_command/task.rb', line 78 def report context[:report] ||= {} 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_metrics_and_methods ⇒ Object
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_remote ⇒ Object
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_ref ⇒ Object
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 |
#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_metrics_and_methods ⇒ Object
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_remote ⇒ Object
51 52 53 |
# File 'lib/3scale_toolbox/commands/service_command/copy_command/task.rb', line 51 def target_remote context[:target_remote] end |