Sha256: 62b65080bda9ca9ff4b9ffd126ebf6152f07b527937a56e56e42510904efee20
Contents?: true
Size: 1.29 KB
Versions: 1
Compression:
Stored size: 1.29 KB
Contents
module Sprangular class OrderSerializer < BaseSerializer attributes *order_attributes attributes | [:display_total, :display_item_total, :display_ship_total, :display_tax_total, :checkout_steps] attribute :total_quantity attribute :token def total_quantity object.line_items.sum(:quantity) end def token object.guest_token end has_one :bill_address, serializer: Sprangular::AddressSerializer has_one :ship_address, serializer: Sprangular::AddressSerializer has_many :line_items, serializer: Sprangular::LineItemSerializer has_many :payments, serializer: Sprangular::PaymentSerializer has_many :shipments, serializer: Sprangular::SmallShipmentSerializer has_many :adjustments, serializer: Sprangular::AdjustmentSerializer has_many :products, serializer: Sprangular::ProductSerializer attribute :permissions def permissions { can_update: current_ability.can?(:update, object) } end attribute :use_billing def use_billing object.bill_address == object.ship_address end # TODO Handle order state-based attributes # def attributes # super.tap do |attrs| # # case object. # end # end private def current_ability Spree::Ability.new(scope) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sprangular-0.1.0 | app/serializers/sprangular/order_serializer.rb |