-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
What happens when you want to override methods with default values?
For instance:
# Get current line item for variant if exists
# Add variant qty to line_item
def add(variant, quantity = 1, currency = nil, shipment = nil)
line_item = order.find_line_item_by_variant(variant)
add_to_line_item(line_item, variant, quantity, currency, shipment)
endGuess it must be done like so:
# Get current line item for variant if exists
# Add variant qty to line_item
durably_decorate :add, mode: 'soft', sha: '' do |variant, quantity, currency, shipment|
quantity ||= 1
currency ||= nil
shipment ||= nil
# If variant is a gift card we say order doesn't already contain it so that each gift card is it's own line item.
if variant.product.is_gift_card?
line_item = nil
else
line_item = order.find_line_item_by_variant(variant)
end
add_to_line_item(line_item, variant, quantity, currency, shipment)
endUnless the decorated add remembers the variables default values which I'm guessing it doesn't. Is it even possible?
Or is this going to cause add to always require those variables to be passed in?
Metadata
Metadata
Assignees
Labels
No labels