Sha256: b51928eeab08d8cfa3d6df8024b9369a7a9646e906a24856a5605297cd733728
Contents?: true
Size: 934 Bytes
Versions: 2
Compression:
Stored size: 934 Bytes
Contents
module MWS module Orders module Helper class StructuredList KEYS = { order_status: %w(OrderStatus Status), marketplace_id: %w(MarketplaceId Id), fulfillment_channel: %w(FulfillmentChannel Channel), payment_method: %w(PaymentMethod), tfm_shipment_status: %w(TFMShipmentStatus Status), amazon_order_id: %w(AmazonOrderId Id) } attr :keys def self.handle?(key) KEYS.has_key?(key) end def initialize(key) @keys = KEYS.fetch(key) end def build(values) Array(values) .each_with_index .reduce(Hash.new) { |hsh, (v, i)| hsh.merge(composite_key(i + 1) => v) } end private def composite_key(index) (keys.dup << index).join('.') end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mws-orders-0.0.2 | lib/mws/orders/helpers/structured_list.rb |
mws-orders-0.0.1 | lib/mws/orders/helpers/structured_list.rb |