Class: ConvenientService::Service::Plugins::CollectsServicesInException::Commands::ExtractServiceDetails

Inherits:
ConvenientService::Support::Command show all
Defined in:
lib/convenient_service/service/plugins/collects_services_in_exception/commands/extract_service_details.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ConvenientService::Support::Command

[], call

Constructor Details

#initialize(service:, method:) ⇒ void

Parameters:



25
26
27
28
# File 'lib/convenient_service/service/plugins/collects_services_in_exception/commands/extract_service_details.rb', line 25

def initialize(service:, method:)
  @service = service
  @method = method
end

Instance Attribute Details

#methodObject (readonly)

Returns the value of attribute method.



19
20
21
# File 'lib/convenient_service/service/plugins/collects_services_in_exception/commands/extract_service_details.rb', line 19

def method
  @method
end

#serviceObject (readonly)

Returns the value of attribute service.



13
14
15
# File 'lib/convenient_service/service/plugins/collects_services_in_exception/commands/extract_service_details.rb', line 13

def service
  @service
end

Instance Method Details

#callHash{Symbol => Object}

Returns:

  • (Hash{Symbol => Object})


33
34
35
# File 'lib/convenient_service/service/plugins/collects_services_in_exception/commands/extract_service_details.rb', line 33

def call
  {instance: service, trigger: trigger}
end

#first_not_completed_stepConvenientService::Service::Plugins::CanHaveSteps::Entities::Step?



56
57
58
# File 'lib/convenient_service/service/plugins/collects_services_in_exception/commands/extract_service_details.rb', line 56

def first_not_completed_step
  Utils.memoize_including_falsy_values(self, :@first_not_completed_step) { service.steps.find(&:not_completed?) }
end

#triggerHash{Symbol => Object}

Returns:

  • (Hash{Symbol => Object})


45
46
47
48
49
50
51
# File 'lib/convenient_service/service/plugins/collects_services_in_exception/commands/extract_service_details.rb', line 45

def trigger
  return {method: ":#{method}"} if method != :result
  return {method: ":result"} if service.steps.none?
  return {step: "Unknown Step", index: -1} unless first_not_completed_step

  {step: first_not_completed_step.printable_service, index: first_not_completed_step.index}
end