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.



23
24
25
26
27
# File 'lib/wasabi/resolver.rb', line 23

def initialize(document, request = nil, adapter = nil)
  @document = document
  @request  = request || Faraday.new
  @adapter  = adapter
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



29
30
31
# File 'lib/wasabi/resolver.rb', line 29

def adapter
  @adapter
end

#documentObject (readonly)

Returns the value of attribute document.



29
30
31
# File 'lib/wasabi/resolver.rb', line 29

def document
  @document
end

#requestObject (readonly)

Returns the value of attribute request.



29
30
31
# File 'lib/wasabi/resolver.rb', line 29

def request
  @request
end

Instance Method Details

#resolveObject

Raises:

  • (ArgumentError)


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

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