Class: Comable::CartOwner::Cart

Inherits:
Array
  • Object
show all
Defined in:
app/models/concerns/comable/cart_owner.rb

Instance Method Summary collapse

Instance Method Details

#countObject Also known as: size



36
37
38
# File 'app/models/concerns/comable/cart_owner.rb', line 36

def count
  sum(&:quantity)
end

#errorsObject

TODO: Refactoring



43
44
45
46
47
48
49
# File 'app/models/concerns/comable/cart_owner.rb', line 43

def errors
  ActiveModel::Errors.new(self).tap do |obj|
    map(&:errors).map(&:full_messages).flatten.each do |full_message|
      obj[:base] << full_message
    end
  end
end

#priceObject



32
33
34
# File 'app/models/concerns/comable/cart_owner.rb', line 32

def price
  sum(&:current_subtotal_price)
end