Class: Wasabi::Resolver

Inherits:
Object
  • Object
show all
Defined in:
lib/wasabi/resolver.rb

Overview

Wasabi::Resolver

Resolves local and remote WSDL documents.

Defined Under Namespace

Classes: HTTPError

Constant Summary collapse

URL =
/^http[s]?:/
XML =
/^</

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document, request = nil, adapter = nil) ⇒ Resolver

Returns a new instance of Resolver.


21
22
23
24
25
# File 'lib/wasabi/resolver.rb', line 21

def initialize(document, request = nil, adapter = nil)
  @document = document
  @request  = request || HTTPI::Request.new
  @adapter  = adapter
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter


27
28
29
# File 'lib/wasabi/resolver.rb', line 27

def adapter
  @adapter
end

#documentObject (readonly)

Returns the value of attribute document


27
28
29
# File 'lib/wasabi/resolver.rb', line 27

def document
  @document
end

#requestObject (readonly)

Returns the value of attribute request


27
28
29
# File 'lib/wasabi/resolver.rb', line 27

def request
  @request
end

Instance Method Details

#resolveObject

Raises:

  • (ArgumentError)

29
30
31
32
33
34
35
36
37
# File 'lib/wasabi/resolver.rb', line 29

def resolve
  raise ArgumentError, "Unable to resolve: #{document.inspect}" unless document

  case document
    when URL then load_from_remote
    when XML then document
    else          load_from_disc
  end
end