Sha256: 12a1f31c79e7817362937589c94e8b398c074ba8dbe9826bda880f3e17ce2a57

Contents?: true

Size: 868 Bytes

Versions: 4

Compression:

Stored size: 868 Bytes

Contents

# coding: utf-8

require 'forwardable'

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

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

    class << self

      include Forwardable

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

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

      def parse(xml)
        self.new(::Cacofonix::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

    delegate :interpret

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

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cacofonix-0.10.3 lib/cacofonix/wrappers/simple_product.rb
cacofonix-0.10.2 lib/cacofonix/wrappers/simple_product.rb
cacofonix-0.10.1 lib/cacofonix/wrappers/simple_product.rb
cacofonix-0.10.0 lib/cacofonix/wrappers/simple_product.rb