Files
openfoodnetwork/app/serializers/api/admin/subscription_customer_serializer.rb
David Cook 0225db6840 Refactor without setter methods
This class was originally built to flexibly accept paramters in any order. It also allowed you to specify multiple of the same type of parameter, with the later one overriding the earlier.

This is too flexible and likely to cause mistakes. And besides, we don't use that feature!
2025-05-05 12:59:27 +10:00

18 lines
491 B
Ruby

# frozen_string_literal: true
module Api
module Admin
# Used by admin subscription form
# Searches for a ship and bill addresses for the customer
# where they are not already explicitly set
class SubscriptionCustomerSerializer < CustomerSerializer
delegate :bill_address, to: :finder
delegate :ship_address, to: :finder
def finder
@finder ||= OpenFoodNetwork::AddressFinder.new(customer: object, email: object.email)
end
end
end
end