summaryrefslogtreecommitdiff
path: root/app/controllers/serializers/product_serializer.rb
blob: 8e1ac11ae58a5b5e48642d4b27607800d3cac00e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

module Serializers
  # ProductSerializer
  class ProductSerializer < BaseSerializer
    include Rails.application.routes.url_helpers
    extend ActionView::RoutingUrlFor

    attributes :name, :unitary_price, :bulk_price, :available_quantity, :categories

    attribute :picture do |object|
      object.picture.url
    end

    attribute :company do |object|
      { name: object.company_name, short_name: object.company_short_name }
    end
  end
end