Class: SOAP::SOAPReference

Inherits:
XSD::NSDBase
  • Object
show all
Extended by:
SOAPModuleUtils
Includes:
SOAPBasetype
Defined in:
lib/soap/baseData.rb

Overview

Convenience datatypes.

Constant Summary

Constants included from SOAP

AttrActor, AttrArrayType, AttrArrayTypeName, AttrEncodingStyle, AttrEncodingStyleName, AttrMustUnderstand, AttrMustUnderstandName, AttrOffset, AttrOffsetName, AttrPosition, AttrPositionName, AttrRoot, AttrRootName, Base64Literal, EleBody, EleBodyName, EleEnvelope, EleEnvelopeName, EleFault, EleFaultActor, EleFaultActorName, EleFaultCode, EleFaultCodeName, EleFaultDetail, EleFaultDetailName, EleFaultName, EleFaultString, EleFaultStringName, EleHeader, EleHeaderName, EncodingNamespace, EnvelopeNamespace, LiteralNamespace, MediaType, NextActor, PropertyName, SOAPNamespaceTag, TypeMap, VERSION, ValueArray, ValueArrayName, XSDNamespaceTag, XSINamespaceTag

Instance Attribute Summary collapse

Attributes included from SOAPType

#definedtype, #elename, #encodingstyle, #extraattr, #id, #parent, #position, #precedents, #root

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SOAPModuleUtils

decode

Methods included from SOAPType

#inspect, #rootnode

Constructor Details

#initialize(obj = nil) ⇒ SOAPReference

Override the definition in SOAPBasetype.


115
116
117
118
119
120
121
# File 'lib/soap/baseData.rb', line 115

def initialize(obj = nil)
  super()
  @type = XSD::QName::EMPTY
  @refid = nil
  @obj = nil
  __setobj__(obj) if obj
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(msg_id, *params) ⇒ Object

Why don't I use delegate.rb? -> delegate requires target object type at initialize time. Why don't I use forwardable.rb? -> forwardable requires a list of forwarding methods.

ToDo: Maybe I should use forwardable.rb and give it a methods list like delegate.rb…


144
145
146
147
148
149
150
# File 'lib/soap/baseData.rb', line 144

def method_missing(msg_id, *params)
  if @obj
    @obj.send(msg_id, *params)
  else
    nil
  end
end

Instance Attribute Details

#refidObject

Returns the value of attribute refid


112
113
114
# File 'lib/soap/baseData.rb', line 112

def refid
  @refid
end

Class Method Details

.create_refid(obj) ⇒ Object


156
157
158
# File 'lib/soap/baseData.rb', line 156

def self.create_refid(obj)
  'id' + obj.__id__.to_s
end

.decode(elename, refidstr) ⇒ Object


160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/soap/baseData.rb', line 160

def self.decode(elename, refidstr)
  if /\A#(.*)\z/ =~ refidstr
    refid = $1
  elsif /\Acid:(.*)\z/ =~ refidstr
    refid = $1
  else
    raise ArgumentError.new("illegal refid #{refidstr}")
  end
  d = super(elename)
  d.refid = refid
  d
end

Instance Method Details

#__getobj__Object


123
124
125
# File 'lib/soap/baseData.rb', line 123

def __getobj__
  @obj
end

#__setobj__(obj) ⇒ Object


127
128
129
130
131
132
133
134
# File 'lib/soap/baseData.rb', line 127

def __setobj__(obj)
  @obj = obj
  @refid = @obj.id || SOAPReference.create_refid(@obj)
  @obj.id = @refid unless @obj.id
  @obj.precedents << self
  # Copies NSDBase information
  @obj.type = @type unless @obj.type
end

#refidstrObject


152
153
154
# File 'lib/soap/baseData.rb', line 152

def refidstr
  '#' + @refid
end