2021-04-22 19:24:08 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# Items that can be added to the shopping cart
|
|
|
|
module CartItem; end
|
|
|
|
|
|
|
|
# This is an abstract class implemented by classes that can be added to the shopping cart
|
|
|
|
class CartItem::BaseItem
|
2021-05-31 15:39:56 +02:00
|
|
|
attr_reader :errors
|
|
|
|
|
|
|
|
def initialize(*)
|
|
|
|
@errors = {}
|
|
|
|
end
|
|
|
|
|
2021-04-22 19:24:08 +02:00
|
|
|
def price
|
|
|
|
{ elements: {}, amount: 0 }
|
|
|
|
end
|
2021-04-23 12:52:06 +02:00
|
|
|
|
|
|
|
def name
|
|
|
|
''
|
|
|
|
end
|
2021-05-21 18:25:18 +02:00
|
|
|
|
2021-05-31 15:39:56 +02:00
|
|
|
# This method run validations at cart-level, possibly using the other items in the cart, to validate the current one.
|
|
|
|
# Other validations that may occurs at record-level (ActiveRecord validations) can't be related to other items.
|
|
|
|
def valid?(_all_items)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2021-05-21 18:25:18 +02:00
|
|
|
def to_object; end
|
2022-03-18 19:44:30 +01:00
|
|
|
|
|
|
|
def type
|
|
|
|
''
|
|
|
|
end
|
2021-04-22 19:24:08 +02:00
|
|
|
end
|