Module: GiftCards::OrderConcerns::InstanceMethods

Defined in:
app/models/concerns/spree/gift_cards/order_concerns.rb

Instance Method Summary collapse

Instance Method Details

#finalize!Object



24
25
26
27
28
29
30
# File 'app/models/concerns/spree/gift_cards/order_concerns.rb', line 24

def finalize!
  super
  inventory_units = self.inventory_units
  gift_cards.each_with_index do |gift_card, index|
    gift_card.make_redeemable!(purchaser: user, inventory_unit: inventory_units[index])
  end
end

#gift_card_match(line_item, options) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'app/models/concerns/spree/gift_cards/order_concerns.rb', line 14

def gift_card_match(line_item, options)
  return true unless line_item.gift_card?
  return true unless options["gift_card_details"]
  line_item.gift_cards.any? do |gift_card|
    gc_detail_set = gift_card.details.stringify_keys.except("send_email_at").to_set
    options_set = options["gift_card_details"].except("send_email_at").to_set
    gc_detail_set.superset?(options_set)
  end
end

#send_gift_card_emailsObject



32
33
34
35
36
37
38
# File 'app/models/concerns/spree/gift_cards/order_concerns.rb', line 32

def send_gift_card_emails
  gift_cards.each do |gift_card|
    if gift_card.send_email_at.nil? || gift_card.send_email_at <= DateTime.now
      gift_card.send_email
    end
  end
end