Class: ActionService::Protocol::Soap::SoapMapping

Inherits:
Object
  • Object
show all
Defined in:
lib/action_service/protocol/soap.rb

Direct Known Subclasses

SoapArrayMapping

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mapper, type_name, ruby_klass, soap_klass, registry_mapping, custom_type = false) ⇒ SoapMapping

Returns a new instance of SoapMapping.



322
323
324
325
326
327
328
329
330
# File 'lib/action_service/protocol/soap.rb', line 322

def initialize(mapper, type_name, ruby_klass, soap_klass, registry_mapping,
               custom_type=false)
  @mapper = mapper
  @type_name = type_name
  @ruby_klass = ruby_klass
  @soap_klass = soap_klass
  @registry_mapping = registry_mapping
  @custom_type = custom_type
end

Instance Attribute Details

#registry_mappingObject (readonly)

Returns the value of attribute registry_mapping.



320
321
322
# File 'lib/action_service/protocol/soap.rb', line 320

def registry_mapping
  @registry_mapping
end

#ruby_klassObject (readonly)

Returns the value of attribute ruby_klass.



318
319
320
# File 'lib/action_service/protocol/soap.rb', line 318

def ruby_klass
  @ruby_klass
end

#soap_klassObject (readonly)

Returns the value of attribute soap_klass.



319
320
321
# File 'lib/action_service/protocol/soap.rb', line 319

def soap_klass
  @soap_klass
end

Instance Method Details

#custom_type?Boolean

Returns:

  • (Boolean)


336
337
338
# File 'lib/action_service/protocol/soap.rb', line 336

def custom_type?
  @custom_type
end

#each_attribute(&block) ⇒ Object



349
350
351
352
353
354
355
356
357
# File 'lib/action_service/protocol/soap.rb', line 349

def each_attribute(&block)
  if @ruby_klass.respond_to?(:members)
    @ruby_klass.members.each do |name, klass|
      name = name.to_s
      mapping = @mapper.lookup(klass)
      yield name, mapping.qualified_type_name, mapping
    end
  end
end

#is_xsd_type?(klass) ⇒ Boolean

Returns:

  • (Boolean)


359
360
361
# File 'lib/action_service/protocol/soap.rb', line 359

def is_xsd_type?(klass)
  klass.ancestors.include?(XSD::NSDBase)
end

#qualified_type_nameObject



340
341
342
343
344
345
346
347
# File 'lib/action_service/protocol/soap.rb', line 340

def qualified_type_name
  name = type_name
  if custom_type?
    "typens:#{name}"
  else
    xsd_type_for(@soap_klass)
  end
end

#type_nameObject



332
333
334
# File 'lib/action_service/protocol/soap.rb', line 332

def type_name
  @type_name
end

#xsd_type_for(klass) ⇒ Object



363
364
365
366
367
368
369
# File 'lib/action_service/protocol/soap.rb', line 363

def xsd_type_for(klass)
  ns = XSD::NS.new
  ns.assign(XSD::Namespace, SOAP::XSDNamespaceTag)
  xsd_klass = klass.ancestors.find{|c| c.const_defined?('Type')}
  return ns.name(XSD::AnyTypeName) unless xsd_klass
  ns.name(xsd_klass.const_get('Type'))
end