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

- (MappingSet) initialize

Returns a new instance of MappingSet



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

+ (Object) default



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

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

Instance Method Details

- (Object) <<(mapping)



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

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

- (Object) dup



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

- (Object) find(type)



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

def find(type)
  @cache[type]
end

- (Object) find!(type)



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

- (Object) remove(mapping)

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

- (Object) requires(type)



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

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

- (Object) ruby_type(type)



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

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

- (Object) to_ruby(type, value)



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

- (Object) to_xml(type, value)



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