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.



317
318
319
320
321
322
323
324
325
# File 'lib/action_service/protocol/soap.rb', line 317

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.



315
316
317
# File 'lib/action_service/protocol/soap.rb', line 315

def registry_mapping
  @registry_mapping
end

#ruby_klassObject (readonly)

Returns the value of attribute ruby_klass.



313
314
315
# File 'lib/action_service/protocol/soap.rb', line 313

def ruby_klass
  @ruby_klass
end

#soap_klassObject (readonly)

Returns the value of attribute soap_klass.



314
315
316
# File 'lib/action_service/protocol/soap.rb', line 314

def soap_klass
  @soap_klass
end

Instance Method Details

#custom_type?Boolean

Returns:

  • (Boolean)


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

def custom_type?
  @custom_type
end

#each_attribute(&block) ⇒ Object



344
345
346
347
348
349
350
351
352
# File 'lib/action_service/protocol/soap.rb', line 344

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)


354
355
356
# File 'lib/action_service/protocol/soap.rb', line 354

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

#qualified_type_nameObject



335
336
337
338
339
340
341
342
# File 'lib/action_service/protocol/soap.rb', line 335

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

#type_nameObject



327
328
329
# File 'lib/action_service/protocol/soap.rb', line 327

def type_name
  @type_name
end

#xsd_type_for(klass) ⇒ Object



358
359
360
361
362
363
364
# File 'lib/action_service/protocol/soap.rb', line 358

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