Module: MuckCommerce::Models::MuckCart

Extended by:
ActiveSupport::Concern
Defined in:
lib/muck-commerce/models/cart.rb

Instance Method Summary collapse

Instance Method Details

#before_createObject



23
24
25
# File 'lib/muck-commerce/models/cart.rb', line 23

def before_create
  generate_token
end

#empty?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/muck-commerce/models/cart.rb', line 19

def empty?
  self.items.empty?
end

#generate_tokenObject



27
28
29
# File 'lib/muck-commerce/models/cart.rb', line 27

def generate_token
  self.token = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{self.id}--")
end

#itemsObject

Override this method in your cart



32
33
34
# File 'lib/muck-commerce/models/cart.rb', line 32

def items
  []
end