Sha256: 1b39ddcb1de1520c3c17b63dccb7ee4eefb34a8fe24e03b29d9ebc423cb113f4

Contents?: true

Size: 1.3 KB

Versions: 17

Compression:

Stored size: 1.3 KB

Contents

# Mixin this module into any classes that act as an order_total.
#
# You need to overwrite the price, name and description methods
#
module ActiveCart
  module OrderTotal
    
    # Returns a boolean depending if the order total is active in this particular cart
    #
    #   @order_total.active? # => true
    #
    def active?
      @active || false
    end

    # Make a particular order_total active
    #
    #   @order_total.active = true
    #   @order_total.active? # => true
    #
    #   @order_total.active = false
    #   @order_total.active? # => falese
    #
    def active=(active)
      @active = active
    end

    # Returns the adjustment caused by this order_total object. Takes a cart object as a parameter, allowing the object to interrogate the items in the cart. 
    #
    # This must be overriden in the mixee class, otherwise it will throw a NotImplementedError
    #
    #   @order.price(@cart) => 2
    #
    def price(cart)
      raise NotImplementedError
    end

    # Returns the friendly name of the order total. Can be used for display (Such as on an invoices etc)
    #
    # This must be overriden in the mixee class, otherwise it will throw a NotImplementedError
    #
    #   @order.name # => 'My awesome order total class'
    #
    def name
      raise NotImplementedError
    end
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
galvinhsiu-active_cart-0.0.20 lib/active_cart/order_total.rb
galvinhsiu-active_cart-0.0.19 lib/active_cart/order_total.rb
active_cart-0.0.18 lib/active_cart/order_total.rb
active_cart-0.0.17 lib/active_cart/order_total.rb
active_cart-0.0.16 lib/active_cart/order_total.rb
active_cart-0.0.15 lib/active_cart/order_total.rb
active_cart-0.0.14 lib/active_cart/order_total.rb
active_cart-0.0.13 lib/active_cart/order_total.rb
active_cart-0.0.12 lib/active_cart/order_total.rb
active_cart-0.0.11 lib/active_cart/order_total.rb
active_cart-0.0.10.1 lib/active_cart/order_total.rb
active_cart-0.0.10 lib/active_cart/order_total.rb
active_cart-0.0.9 lib/active_cart/order_total.rb
active_cart-0.0.8 lib/active_cart/order_total.rb
active_cart-0.0.7 lib/active_cart/order_total.rb
active_cart-0.0.6 lib/active_cart/order_total.rb
active_cart-0.0.5 lib/active_cart/order_total.rb