class PolicySerializer < ActiveModel::Serializer
  root false
  attributes :id, :policy_holder, :premium_amount, :industry, :carrier, :agent, :updated_at

  def premium_amount
    object.premium_amount.to_f
  end

  def industry
    {
      id: object.industry.id,
      name: object.industry.name
    }
  end

  def carrier
    {
      id: object.carrier.id,
      name: object.carrier.name
    }
  end

  def agent
    {
      id: object.agent.id,
      name: object.agent.name
    }
  end
end
