Class: Wasabi::Document

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

Overview

Wasabi::Document

Represents a WSDL document.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document = nil) ⇒ Document

Accepts a WSDL document to parse.



12
13
14
# File 'lib/wasabi/document.rb', line 12

def initialize(document = nil)
  self.document = document
end

Instance Attribute Details

#documentObject

Returns the value of attribute document.



16
17
18
# File 'lib/wasabi/document.rb', line 16

def document
  @document
end

#endpointObject

Returns the SOAP endpoint.



24
25
26
# File 'lib/wasabi/document.rb', line 24

def endpoint
  @endpoint ||= parser.endpoint
end

#namespaceObject

Returns the target namespace.



32
33
34
# File 'lib/wasabi/document.rb', line 32

def namespace
  @namespace ||= parser.namespace
end

Instance Method Details

#document?Boolean

Returns whether a document was set.

Returns:

  • (Boolean)


19
20
21
# File 'lib/wasabi/document.rb', line 19

def document?
  !!document
end

#element_form_defaultObject

Returns the value of elementFormDefault.



40
41
42
# File 'lib/wasabi/document.rb', line 40

def element_form_default
  @element_form_default ||= parser.element_form_default
end

#operationsObject

Returns a map of SOAP operations.



60
61
62
# File 'lib/wasabi/document.rb', line 60

def operations
  @operations ||= parser.operations
end

#parserObject

Parses the WSDL document and returns the Wasabi::Parser.



102
103
104
# File 'lib/wasabi/document.rb', line 102

def parser
  @parser ||= guard_parse && parse
end

#soap_action(key) ⇒ Object

Returns the SOAP action for a given key.



50
51
52
# File 'lib/wasabi/document.rb', line 50

def soap_action(key)
  operations[key][:action] if operations[key]
end

#soap_actionsObject

Returns a list of available SOAP actions.



45
46
47
# File 'lib/wasabi/document.rb', line 45

def soap_actions
  @soap_actions ||= parser.operations.keys
end

#soap_input(key) ⇒ Object

Returns the SOAP input for a given key.



55
56
57
# File 'lib/wasabi/document.rb', line 55

def soap_input(key)
  operations[key][:input] if operations[key]
end

#type_definitionsObject



75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/wasabi/document.rb', line 75

def type_definitions
  @type_definitions ||= begin
    result = []
    parser.types.each do |type, info|
      (info.keys - [:namespace]).each do |field|
        field_type = info[field][:type]
        tag, namespace = field_type.split(":").reverse
        result << [[type, field], tag] if user_defined(namespace)
      end
    end if document?
    result
  end
end

#type_namespacesObject



64
65
66
67
68
69
70
71
72
73
# File 'lib/wasabi/document.rb', line 64

def type_namespaces
  @type_namespaces ||= begin
    namespaces = []
    parser.types.each do |type, info|
      namespaces << [[type], info[:namespace]]
      (info.keys - [:namespace]).each { |field| namespaces << [[type, field], info[:namespace]] }
    end if document?
    namespaces
  end
end

#user_defined(namespace) ⇒ Object

Returns whether the given namespace was defined manually.



90
91
92
93
# File 'lib/wasabi/document.rb', line 90

def user_defined(namespace)
  uri = parser.namespaces[namespace]
  !(uri =~ %r{^http://schemas.xmlsoap.org} || uri =~ %r{^http://www.w3.org})
end

#xmlObject

Returns the raw WSDL document. Can be used as a hook to extend the library.



97
98
99
# File 'lib/wasabi/document.rb', line 97

def xml
  @xml ||= document
end