Sha256: 71580c984101a0eef975d8a602d755ad604cac67e7759577a40e416302a45abc

Contents?: true

Size: 769 Bytes

Versions: 10

Compression:

Stored size: 769 Bytes

Contents

module ThreeScaleToolbox
  module CRD
    module MappingRuleSerializer
      def to_cr
        {
          'httpMethod' => http_method,
          'pattern' => pattern,
          'metricMethodRef' => metric_method_ref,
          'increment' => delta,
          'last' => last,
        }
      end

      def metric_method_ref
        if (method = service.methods.find { |m| m.id == metric_id })
          method.system_name
        elsif (metric = service.metrics.find { |m| m.id == metric_id })
          metric.system_name
        else
          raise ThreeScaleToolbox::Error, "Unexpected error. Service #{service.system_name} " \
            "mapping rule #{id} referencing to metric id #{metric_id} which has not been found"
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
3scale_toolbox-1.0.1 lib/3scale_toolbox/crds/mapping_rule_dump.rb
3scale_toolbox-1.0.0 lib/3scale_toolbox/crds/mapping_rule_dump.rb
3scale_toolbox-0.20.0 lib/3scale_toolbox/crds/mapping_rule_dump.rb
3scale_toolbox-0.19.3 lib/3scale_toolbox/crds/mapping_rule_dump.rb
3scale_toolbox-0.19.2 lib/3scale_toolbox/crds/mapping_rule_dump.rb
3scale_toolbox-0.19.1 lib/3scale_toolbox/crds/mapping_rule_dump.rb
3scale_toolbox-0.19.0 lib/3scale_toolbox/crds/mapping_rule_dump.rb
3scale_toolbox-0.18.3 lib/3scale_toolbox/crds/mapping_rule_dump.rb
3scale_toolbox-0.18.2 lib/3scale_toolbox/crds/mapping_rule_dump.rb
3scale_toolbox-0.18.0 lib/3scale_toolbox/crds/mapping_rule_dump.rb