Class: PackageLabelsService

Inherits:
ApplicationService show all
Includes:
PackageLabelGenerator
Defined in:
app/services/package_labels_service.rb

Overview

Service class to retrieve package custom labels

Constant Summary

Constants included from PackageLabelGenerator

PackageLabelGenerator::DEFAULT_LABEL_TYPE

Instance Attribute Summary

Attributes inherited from ApplicationService

#object

Instance Method Summary collapse

Methods included from PackageLabelGenerator

#generate_label_names_for_package, #generate_labels_for_package

Methods inherited from ApplicationService

#execute, #execute!

Constructor Details

#initialize(restaurant_package_ids) ⇒ PackageLabelsService

Initializes the service with the given restaurant package IDs.

Parameters:

  • restaurant_package_ids (Array<Integer>)

    the IDs of the restaurant packages



11
12
13
# File 'app/services/package_labels_service.rb', line 11

def initialize(restaurant_package_ids)
  @restaurant_package_ids = restaurant_package_ids
end

Instance Method Details

#cache_keyObject



24
25
26
# File 'app/services/package_labels_service.rb', line 24

def cache_key
  HhPackage::RestaurantPackage.where(id: @restaurant_package_ids).cache_key
end

#callArray<Hash>

Calls the service and returns an array of package custom labels for each restaurant package.

Returns:

  • (Array<Hash>)

    an array of package custom labels, where each label contains a package ID and an array of custom labels



18
19
20
21
22
# File 'app/services/package_labels_service.rb', line 18

def call
  @restaurant_package_ids.map do |restaurant_package_id|
    package_custom_labels(restaurant_package_id)
  end
end