Sha256: bbba3c81f9d5bd2f2026f01b3c1fefb2fa6e7529876cb1566a826fc09757de54

Contents?: true

Size: 807 Bytes

Versions: 1

Compression:

Stored size: 807 Bytes

Contents

module Shopper
  module OrderSummary
    class OrderDecorator < SimpleDelegator
      include Shopper::ViewHelpers

      def initialize(order, deficit_method: :show_zero, position: :right)
        @deficit_method = deficit_method
        @position = position
        super order
      end

      attr_reader :position

      def subtotal
        @subtotal = wrap(__getobj__.subtotal)
      end

      def coupon
        @coupon = wrap(__getobj__.saved_by_coupon)
      end

      def delivery
        @delivery = wrap(__getobj__.delivery_price)
      end

      def order_total
        @order_total = wrap(__getobj__.total)
      end

      private

      def wrap(input)
        return false if input.zero? && @deficit_method == :hide
        helpers.number_to_currency(input)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shoppper-0.1.0 app/decorators/shopper/order_summary/order_decorator.rb