Module: ThreeScaleToolbox::CRD::MappingRuleSerializer

Included in:
Entities::MappingRule
Defined in:
lib/3scale_toolbox/crds/mapping_rule_dump.rb

Instance Method Summary collapse

Instance Method Details

#metric_method_refObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/3scale_toolbox/crds/mapping_rule_dump.rb', line 14

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

#to_crObject



4
5
6
7
8
9
10
11
12
# File 'lib/3scale_toolbox/crds/mapping_rule_dump.rb', line 4

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