Sha256: 954c186109dda181a4120f1d938e9449e56bbccfb14b1891ffd4fc521d4dacbf

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

require "wasabi"
require "httpi/request"

module Savon
  module Wasabi

    # = Savon::Wasabi::Document
    #
    # Extends the <tt>Wasabi::Document</tt> to extend its document handling by
    # adding support for remote and local WSDL documents.
    class Document < ::Wasabi::Document

      # Hooks into Wasabi and extends its document handling.
      def xml
        @xml ||= document.kind_of?(String) ? resolve_document : document
      end

      # Sets up and returns the <tt>HTTPI::Request</tt>.
      def request
        @request ||= HTTPI::Request.new
        @request.url = document
        @request
      end

      # Sets the <tt>HTTPI::Request</tt> for remote WSDL documents.
      attr_writer :request

    private

      # Resolves and returns the raw WSDL document.
      def resolve_document
        case document
          when /^http[s]?:/ then HTTPI.get(request).body
          when /^</         then document
          else                   File.read(document)
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
savon-0.9.4 lib/savon/wasabi/document.rb