Class: InventoryUnitSerializer

Inherits:
ActiveModel::Serializer
  • Object
show all
Defined in:
app/serializers/inventory_unit_serializer.rb

Instance Method Summary collapse

Instance Method Details

#nameObject



18
19
20
# File 'app/serializers/inventory_unit_serializer.rb', line 18

def name
  object.variant.name
end

#priceObject



10
11
12
# File 'app/serializers/inventory_unit_serializer.rb', line 10

def price
  object.line_item.price.round(2).to_f
end

#product_idObject



14
15
16
# File 'app/serializers/inventory_unit_serializer.rb', line 14

def product_id
  object.variant.sku
end

#quantityObject



6
7
8
# File 'app/serializers/inventory_unit_serializer.rb', line 6

def quantity
  object.respond_to?(:quantity) ? object.quantity : 1
end