Sha256: c905c768475bbbf3f2152e3dd3a7c0a5227b856357f8f9e78d7b22155629c29a

Contents?: true

Size: 737 Bytes

Versions: 1

Compression:

Stored size: 737 Bytes

Contents

require "super_formatter/import"
require "super_formatter/shopline/head"
require "super_formatter/shopline/row"
require "super_formatter/shopline/order"

module SuperFormatter
  module Shopline
    class Import < ::SuperFormatter::Import

      callable do
        build_rows!(Head, Row)
        self.orders = merged_orders!.values
        self.orders
      end

      protected

      def merged_orders!
        array = {}
        rows.each do |row|
          if array[row.order_id].present?
            # 存在 Merge Item
            array[row.order_id].merge!(row)
          else
            # 不存在建立 Order
            array[row.order_id] = Order.new(row)
          end
        end
        array
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
super_tools-3.0.1 lib/super_formatter/shopline/import.rb