Class: SolidusImporter::Processors::CustomerAddress

Inherits:
Base
  • Object
show all
Defined in:
lib/solidus_importer/processors/customer_address.rb

Instance Method Summary collapse

Methods inherited from Base

#options

Instance Method Details

#call(context) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/solidus_importer/processors/customer_address.rb', line 6

def call(context)
  @data = context.fetch(:data)

  address = Spree::Address.find_or_create_by(address_attributes)
  return unless address.valid?

  user = context.fetch(:user)
  user.addresses << address
  user.bill_address ||= address
  user.ship_address ||= address
  user.save!
end