Class: WsdlMapper::TypeMapping::MappingSet

Inherits:
Object
  • Object
show all
Defined in:
lib/wsdl_mapper/type_mapping/mapping_set.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMappingSet



4
5
6
7
8
9
# File 'lib/wsdl_mapper/type_mapping/mapping_set.rb', line 4

def initialize
  @list = []
  @cache = Hash.new do |h, k|
    h[k] = get_mapping(k)
  end
end

Class Method Details

.defaultObject



38
39
40
# File 'lib/wsdl_mapper/type_mapping/mapping_set.rb', line 38

def self.default
  @default ||= MappingSet.new
end

Instance Method Details

#<<(mapping) ⇒ Object



11
12
13
14
# File 'lib/wsdl_mapper/type_mapping/mapping_set.rb', line 11

def <<(mapping)
  @list << mapping
  self
end

#dupObject



24
25
26
27
28
29
30
# File 'lib/wsdl_mapper/type_mapping/mapping_set.rb', line 24

def dup
  other = self.class.new
  @list.each do |mapping|
    other << mapping
  end
  other
end

#find(type) ⇒ Object



16
17
18
# File 'lib/wsdl_mapper/type_mapping/mapping_set.rb', line 16

def find(type)
  @cache[type]
end

#find!(type) ⇒ Object



20
21
22
# File 'lib/wsdl_mapper/type_mapping/mapping_set.rb', line 20

def find!(type)
  find(type) || raise(ArgumentError.new("Unknown type: #{type}"))
end

#remove(mapping) ⇒ Object

TODO: test



33
34
35
36
# File 'lib/wsdl_mapper/type_mapping/mapping_set.rb', line 33

def remove(mapping)
  @list.delete mapping
  @cache.delete_if { |_, m| m == mapping }
end

#requires(type) ⇒ Object



54
55
56
# File 'lib/wsdl_mapper/type_mapping/mapping_set.rb', line 54

def requires(type)
  find!(type).requires
end

#ruby_type(type) ⇒ Object



50
51
52
# File 'lib/wsdl_mapper/type_mapping/mapping_set.rb', line 50

def ruby_type(type)
  find!(type).ruby_type
end

#to_ruby(type, value) ⇒ Object



42
43
44
# File 'lib/wsdl_mapper/type_mapping/mapping_set.rb', line 42

def to_ruby(type, value)
  find!(type).to_ruby value
end

#to_xml(type, value) ⇒ Object



46
47
48
# File 'lib/wsdl_mapper/type_mapping/mapping_set.rb', line 46

def to_xml(type, value)
  find!(type).to_xml value
end