How to create a Parameter Object

I’m reading through Ruby Science. Currently I’m at the section on Parameter Objects. It is said that a Parameter Object is a solution to Long Parameter Lists. As an example is shown the recipient object that groups the properties first_name, last_name and email.

But nowhere is shown how the recipient object is created. Can someone show me how to create a Parameter Object?

thanks for your help,

Anthony

It’s normally just a simple class with an attribute for each field, e.g.:

class Recipient
  def initialize(first_name:, last_name:, email:)
    @first_name = first_name
    @last_name = last_name
    @email = email
  end

  attr_reader :first_name, :last_name, :email
end
2 Likes

Oh I see. Thanks Andy.