Sha256: 73774a8b67b249dcd138fa41cb2ae0fad5ff7d87874fdae0cde93641dcd402d2

Contents?: true

Size: 717 Bytes

Versions: 4

Compression:

Stored size: 717 Bytes

Contents

module MoneyS3
  module Builders
    module BaseBuilder
      attr_accessor :name, :data

      def initialize(name, data = {})
        @name = name
        @data = data || {}
      end

      def to_xml
        doc = Ox::Document.new(version: '1.0')
        doc << builder

        Ox.dump(doc, with_xml: true)
      end

      def build_element(name, content)
        element = Ox::Element.new(name)
        if content.respond_to? :attributes
          content.attributes.each { |k, v| element[k] = v }
        end

        if content.respond_to? :value
          element << content.value if content.value
        else
          element << content if content
        end
        element
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
money_s3-0.9.0 lib/money_s3/builders/base_builder.rb
money_s3-0.8.0 lib/money_s3/builders/base_builder.rb
money_s3-0.7.0 lib/money_s3/builders/base_builder.rb
money_s3-0.6.0 lib/money_s3/builders/base_builder.rb