lib/3scale_toolbox/helper.rb in 3scale_toolbox-0.15.0 vs lib/3scale_toolbox/helper.rb in 3scale_toolbox-0.16.0
- old
+ new
@@ -48,9 +48,29 @@
end
def period_already_taken_error?(error)
Array(Hash(error)['period']).any? { |msg| msg.match(/has already been taken/) }
end
+
+ def metrics_mapping(source_metrics, target_metrics)
+ target_metrics.map do |target|
+ source = source_metrics.find do |m|
+ compare_hashes(m, target, ['system_name'])
+ end || {}
+
+ [source['id'], target['id']]
+ end.to_h
+ end
+
+ def application_plan_mapping(source_app_plans, target_app_plans)
+ mapping = target_app_plans.map do |target|
+ source = source_app_plans.find do |app_plan|
+ compare_hashes(app_plan, target, ['system_name'])
+ end || {}
+ [source['id'], target]
+ end
+ mapping.reject { |key, _| key.nil? }
+ end
end
class BooleanTransformer
def call(param_str)
raise ArgumentError unless param_str.is_a?(String)