Module: ThreeScaleToolbox::Commands::PlansCommand::Export::Step

Included in:
ReadAppPlanStep, ReadPlanFeaturesStep, ReadPlanLimitsStep, ReadPlanMethods, ReadPlanMetrics, ReadPlanPricingRulesStep, WriteArtifactsStep
Defined in:
lib/3scale_toolbox/commands/plans_command/export/step.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



12
13
14
# File 'lib/3scale_toolbox/commands/plans_command/export/step.rb', line 12

def context
  @context
end

Instance Method Details

#fileObject



22
23
24
# File 'lib/3scale_toolbox/commands/plans_command/export/step.rb', line 22

def file
  context[:file]
end

#initialize(context) ⇒ Object



14
15
16
# File 'lib/3scale_toolbox/commands/plans_command/export/step.rb', line 14

def initialize(context)
  @context = context
end

#metric_info(elem, elem_name) ⇒ Object



56
57
58
59
60
61
62
63
64
65
# File 'lib/3scale_toolbox/commands/plans_command/export/step.rb', line 56

def metric_info(elem, elem_name)
  if (method = find_method(elem.fetch('metric_id')))
    { 'type' => 'method', 'system_name' => method.fetch('system_name') }
  elsif (metric = find_metric(elem.fetch('metric_id')))
    { 'type' => 'metric', 'system_name' => metric.fetch('system_name') }
  else
    raise ThreeScaleToolbox::Error, "Unexpected error. #{elem_name} #{elem['id']} " \
      "referencing to metric id #{elem.fetch('metric_id')} which has not been found"
  end
end

#planObject



44
45
46
# File 'lib/3scale_toolbox/commands/plans_command/export/step.rb', line 44

def plan
  context[:plan] ||= find_plan
end

#plan_system_nameObject

can be id or system_name



36
37
38
# File 'lib/3scale_toolbox/commands/plans_command/export/step.rb', line 36

def plan_system_name
  context[:plan_system_name]
end

#resultObject



40
41
42
# File 'lib/3scale_toolbox/commands/plans_command/export/step.rb', line 40

def result
  context[:result] ||= {}
end

#serviceObject



18
19
20
# File 'lib/3scale_toolbox/commands/plans_command/export/step.rb', line 18

def service
  context[:service] ||= find_service
end

#service_methodsObject



52
53
54
# File 'lib/3scale_toolbox/commands/plans_command/export/step.rb', line 52

def service_methods
  context[:service_methods] ||= service.methods(service_hits['id'])
end

#service_metricsObject



48
49
50
# File 'lib/3scale_toolbox/commands/plans_command/export/step.rb', line 48

def service_metrics
  context[:service_metrics] ||= service.metrics
end

#service_system_nameObject

can be id or system_name



31
32
33
# File 'lib/3scale_toolbox/commands/plans_command/export/step.rb', line 31

def service_system_name
  context[:service_system_name]
end

#threescale_clientObject



26
27
28
# File 'lib/3scale_toolbox/commands/plans_command/export/step.rb', line 26

def threescale_client
  context[:threescale_client]
end