Class: SOAP::Mapping::Registry::Map

Class | SOAP::Mapping::Registry::Map
In: | soap/mapping/registry.rb
Parent: | Object

### Methods

add clear find_mapped_obj_class find_mapped_soap_class init new obj2soap soap2obj

### Public Class methods

new(registry)

[Source]

    # File soap/mapping/registry.rb, line 179
        def initialize(registry)
          @obj2soap = {}
          @soap2obj = {}
          @registry = registry
        end

### Public Instance methods

add(obj_class, soap_class, factory, info)

Give priority to latter entry.

[Source]

    # File soap/mapping/registry.rb, line 230
        def add(obj_class, soap_class, factory, info)
          info ||= {}
          (@obj2soap[obj_class] ||= []).unshift([soap_class, factory, info])
          (@soap2obj[soap_class] ||= []).unshift([obj_class, factory, info])
        end

clear()

[Source]

    # File soap/mapping/registry.rb, line 236
        def clear
          @obj2soap.clear
          @soap2obj.clear
        end

find_mapped_obj_class(target_soap_class)

[Source]

    # File soap/mapping/registry.rb, line 246
        def find_mapped_obj_class(target_soap_class)
          map = @soap2obj[target_soap_class]
          map.empty? ? nil : map[0][0]
        end

find_mapped_soap_class(target_obj_class)

[Source]

    # File soap/mapping/registry.rb, line 241
        def find_mapped_soap_class(target_obj_class)
          map = @obj2soap[target_obj_class]
          map.empty? ? nil : map[0][1]
        end

init(init_map = [])

Give priority to former entry.

[Source]

    # File soap/mapping/registry.rb, line 222
        def init(init_map = [])
          clear
          init_map.reverse_each do |obj_class, soap_class, factory, info|
            add(obj_class, soap_class, factory, info)
          end
        end

obj2soap(obj)

[Source]

    # File soap/mapping/registry.rb, line 185
        def obj2soap(obj)
          klass = obj.class
          if map = @obj2soap[klass]
            map.each do |soap_class, factory, info|
              ret = factory.obj2soap(soap_class, obj, info, @registry)
              return ret if ret
            end
          end
          ancestors = klass.ancestors
          ancestors.delete(klass)
          ancestors.delete(::Object)
          ancestors.delete(::Kernel)
          ancestors.each do |klass|
            if map = @obj2soap[klass]
              map.each do |soap_class, factory, info|
                if info[:derived_class]
                  ret = factory.obj2soap(soap_class, obj, info, @registry)
                  return ret if ret
                end
              end
            end
          end
          nil
        end

soap2obj(node, klass = nil)

[Source]

    # File soap/mapping/registry.rb, line 210
        def soap2obj(node, klass = nil)
          if map = @soap2obj[node.class]
            map.each do |obj_class, factory, info|
              next if klass and obj_class != klass
              conv, obj = factory.soap2obj(obj_class, node, info, @registry)
              return true, obj if conv
            end
          end
          return false, nil
        end

[Validate]