<commit_before>require 'spec_helper'

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
      def bill_address
        finder.bill_address
      end

      def ship_address
        finder.ship_address
      end

      def finder
        @finder ||= OpenFoodNetwork::AddressFinder.new(object, object.email)
      end
    end<commit_msg>Simplify serialiser with `delegate`<commit_after>require 'spec_helper'

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(object, object.email)
      end
    end
{'fraction_non_alphanumeric': 0.050731707317073174, 'fraction_numerical': 0.0, 'mean_word_length': 3.087649402390438, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '979535', 'n_tokens_mistral': 268, 'n_tokens_neox': 256, 'n_words': 94}