summaryrefslogtreecommitdiff
path: root/app/controllers/serializers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/serializers')
-rw-r--r--app/controllers/serializers/product_serializer.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/app/controllers/serializers/product_serializer.rb b/app/controllers/serializers/product_serializer.rb
new file mode 100644
index 0000000..4a2158d
--- /dev/null
+++ b/app/controllers/serializers/product_serializer.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+module Serializers
+ # ProductSerializer
+ class ProductSerializer < BaseSerializer
+ extend ActionView::RoutingUrlFor
+
+ attributes :name, :unitary_price, :bulk_price, :available_quantity, :categories
+
+ attribute :picture do |object|
+ object.picture.url
+ end
+
+ belongs_to :company, links: {
+ self: :url,
+ related: lambda(object) {
+ company_path(object.company)
+ }
+ }
+ end
+end \ No newline at end of file