Sha256: d2e5fc6ae4694375148268a6b2f46b80d957da37de7682ef6c219243c9e48e0c

Contents?: true

Size: 609 Bytes

Versions: 1

Compression:

Stored size: 609 Bytes

Contents

# coding: utf-8

module ONIX2
  class Stock
    include Virtus.model

    # NOTE: these *should* be numeric fields according to the spec,
    #       but heaps of ONIX files in the wild use text
    attribute :on_hand
    attribute :on_order

    def to_xml
      StockRepresenter.new(self).to_xml
    end

    def self.from_xml(data)
      StockRepresenter.new(self.new).from_xml(data)
    end
  end

  class StockRepresenter < Representable::Decorator
    include Representable::XML

    self.representation_wrap = :Stock

    property :on_hand, as: "OnHand"
    property :on_order, as: "OnOrder"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
onix2-1.0.0 lib/onix2/stock.rb