Sha256: 091c9781e1e4072cd95c58b3716768936627430d459c8f1e25a5a2ce7ae27426

Contents?: true

Size: 576 Bytes

Versions: 2

Compression:

Stored size: 576 Bytes

Contents

require 'pump/collection'
require 'pump/xml'
require 'active_support/concern'

module Pump
  module Object
    extend ActiveSupport::Concern

    def pump_to_xml(options={})
      encoder = self.class.pumps.get(options[:set], :xml)
      if encoder
        encoder.encode(self)
      else
        self.to_xml(options)
      end
    end

    module ClassMethods
      def pumps
        @pumps ||= Pump::Collection.new
      end

      def add_pump(name, set=nil, options={}, &block)
        pumps.add(set, :xml, Pump::Xml.new(name, options, &block))
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pump-0.5.1 lib/pump/object.rb
pump-0.5.0 lib/pump/object.rb