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, generated_klass, soap_klass, registry_mapping, custom_type = false) ⇒ SoapMapping

Returns a new instance of SoapMapping.



392
393
394
395
396
397
398
399
400
401
# File 'lib/action_service/protocol/soap.rb', line 392

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

Instance Attribute Details

#generated_klassObject (readonly)

Returns the value of attribute generated_klass.



388
389
390
# File 'lib/action_service/protocol/soap.rb', line 388

def generated_klass
  @generated_klass
end

#registry_mappingObject (readonly)

Returns the value of attribute registry_mapping.



390
391
392
# File 'lib/action_service/protocol/soap.rb', line 390

def registry_mapping
  @registry_mapping
end

#ruby_klassObject (readonly)

Returns the value of attribute ruby_klass.



387
388
389
# File 'lib/action_service/protocol/soap.rb', line 387

def ruby_klass
  @ruby_klass
end

#soap_klassObject (readonly)

Returns the value of attribute soap_klass.



389
390
391
# File 'lib/action_service/protocol/soap.rb', line 389

def soap_klass
  @soap_klass
end

Instance Method Details

#custom_type?Boolean

Returns:

  • (Boolean)


407
408
409
# File 'lib/action_service/protocol/soap.rb', line 407

def custom_type?
  @custom_type
end

#each_attribute(&block) ⇒ Object



420
421
422
423
424
425
426
427
428
# File 'lib/action_service/protocol/soap.rb', line 420

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)


430
431
432
# File 'lib/action_service/protocol/soap.rb', line 430

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

#qualified_type_nameObject



411
412
413
414
415
416
417
418
# File 'lib/action_service/protocol/soap.rb', line 411

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

#type_nameObject



403
404
405
# File 'lib/action_service/protocol/soap.rb', line 403

def type_name
  @type_name
end

#xsd_type_for(klass) ⇒ Object



434
435
436
437
438
439
440
# File 'lib/action_service/protocol/soap.rb', line 434

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