Sha256: d894c0332486a3aa0990d36ef8f62394264ad7716ed6ae648d559ac5cbd91c7c

Contents?: true

Size: 791 Bytes

Versions: 20

Compression:

Stored size: 791 Bytes

Contents

# Mixin this module into the class you want to act as an item 
#
module ActiveCart
  # 
  module Item
    # A unique id for the item. The Mixee needs to implement this or a NotImplementedError will be thrown
    #
    def id
      raise NotImplementedError
    end

    # A display name for the item. The Mixee needs to implement this or a NotImplementedError will be thrown
    #
    def name
      raise NotImplementedError
    end

    # Returns the quantity of this item in the context of a cart
    #
    def quantity
      @quantity || 0
    end

    # Set the quantity of this item in the context of a cart
    #
    def quantity=(quantity)
      @quantity = quantity
    end

    # Returns the price of this item
    #
    def price
      raise NotImplementedError
    end
  end
end

Version data entries

20 entries across 20 versions & 2 rubygems

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