Starting to restructure data injection

This commit is contained in:
Will Marshall
2014-07-18 11:21:51 +10:00
parent 33611ddb20
commit 562f8dbd4e
9 changed files with 61 additions and 17 deletions

View File

@@ -0,0 +1,11 @@
class Api::ImageSerializer < ActiveModel::Serializer
attributes :id, :alt, :small_url, :large_url
def small_url
object.attachment.url(:small, false)
end
def large_url
object.attachment.url(:large, false)
end
end

View File

@@ -1,3 +1,5 @@
class Api::LineItemSerializer < ActiveModel::Serializer
attributes :id, :variant_id, :quantity, :price
attributes :id, :quantity, :price
has_one :variant, serializer: Api::VariantSerializer
end

View File

@@ -0,0 +1,10 @@
class Api::VariantSerializer < ActiveModel::Serializer
attributes :id, :is_master, :count_on_hand, :name_to_display, :on_demand,
:price
has_many :images, serializer: Api::ImageSerializer
def price
object.price_with_fees(options[:current_distributor], options[:current_order_cycle])
end
end