Sha256: b0f47358600ed34cce1d4cb52ece9be0e96ccd9ce8990c4f3a6197319707b423

Contents?: true

Size: 823 Bytes

Versions: 32

Compression:

Stored size: 823 Bytes

Contents

# coding: utf-8

require 'forwardable'

module ONIX
  # super class for some simplified ONIX::Product wrappers
  class SimpleProduct

    def initialize(product = nil)
      @product = product || ::ONIX::Product.new
    end

    class << self
      
      include Forwardable

      def from_xml(xml)
        self.new(::ONIX::Product.from_xml(xml))
      end

      def parse_file(filename)
        self.new(::ONIX::Product.parse(File.read(filename)))
      end

      def parse(xml)
        self.new(::ONIX::Product.parse(xml))
      end
    
      protected

      def delegate(*args)
        def_delegators :@product, *args
      end
    end

    def product
      @product
    end

    def to_xml
      product.to_xml
    end

    # TODO: add method missing magic to proxy through to the underlying product?

  end
end

Version data entries

32 entries across 32 versions & 2 rubygems

Version Path
onix-0.9.5 lib/onix/simple_product.rb
onix-0.9.4 lib/onix/simple_product.rb
milkfarm-onix-0.8.13 lib/onix/simple_product.rb
milkfarm-onix-0.8.12 lib/onix/simple_product.rb
onix-0.9.3 lib/onix/simple_product.rb
onix-0.9.2 lib/onix/simple_product.rb
onix-0.9.1 lib/onix/simple_product.rb
milkfarm-onix-0.8.11 lib/onix/simple_product.rb
milkfarm-onix-0.8.10 lib/onix/simple_product.rb
onix-0.9.0 lib/onix/simple_product.rb
milkfarm-onix-0.8.9 lib/onix/simple_product.rb
milkfarm-onix-0.8.8 lib/onix/simple_product.rb
milkfarm-onix-0.8.7 lib/onix/simple_product.rb
onix-0.8.5 lib/onix/simple_product.rb
onix-0.8.4 lib/onix/simple_product.rb
milkfarm-onix-0.8.6 lib/onix/simple_product.rb
milkfarm-onix-0.8.5 lib/onix/simple_product.rb
onix-0.8.3 lib/onix/simple_product.rb
milkfarm-onix-0.8.3 lib/onix/simple_product.rb
onix-0.8.2 lib/onix/simple_product.rb