Class: XSD::Mapping::Mapper
Instance Attribute Summary collapse
-
#registry ⇒ Object
readonly
Returns the value of attribute registry.
Class Method Summary collapse
- .find_mapper_for_class(klass) ⇒ Object
- .find_mapper_for_type(qname) ⇒ Object
- .get_qname_from_class(klass) ⇒ Object
- .inherited(klass) ⇒ Object
- .mappers ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#registry ⇒ Object (readonly)
Returns the value of attribute registry.
11 12 13 |
# File 'lib/mappum/xml_transform.rb', line 11 def registry @registry end |
Class Method Details
.find_mapper_for_class(klass) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/mappum/xml_transform.rb', line 16 def self.find_mapper_for_class(klass) klass = const_get(klass) if klass.instance_of?(Symbol) ret_maper=nil #FIXME add cache mappers.each do |mapper| begin sch = mapper.registry.schema_definition_from_class klass ret_maper = mapper unless sch.nil? rescue NoMethodError end end return ret_maper end |
.find_mapper_for_type(qname) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/mappum/xml_transform.rb', line 47 def self.find_mapper_for_type(qname) ret_maper=nil #FIXME add cache mappers.each do |mapper| begin sch = mapper.registry.schema_definition_from_elename qname ret_maper = mapper unless sch.nil? rescue NoMethodError end end return ret_maper end |
.get_qname_from_class(klass) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/mappum/xml_transform.rb', line 29 def self.get_qname_from_class(klass) begin klass = const_get(klass) if klass.instance_of?(Symbol) rescue NameError return nil end ret_qname = nil #FIXME add cache mappers.each do |mapper| begin sch = mapper.registry.schema_definition_from_class klass ret_qname = sch.elename unless sch.nil? rescue NoMethodError end end return ret_qname end |
.inherited(klass) ⇒ Object
12 13 14 15 |
# File 'lib/mappum/xml_transform.rb', line 12 def self.inherited(klass) @@mapper_classes ||= [] @@mapper_classes << klass end |
.mappers ⇒ Object
77 78 79 80 81 82 83 84 |
# File 'lib/mappum/xml_transform.rb', line 77 def self.mappers @@mappers ||= [] @@mapper_classes ||= [] if @@mapper_classes.size > @@mappers.size @@mappers = @@mapper_classes.collect{|k|k.new()} end @@mappers end |
Instance Method Details
#obj2soap(obj, elename = nil, io = nil) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/mappum/xml_transform.rb', line 59 def obj2soap(obj, elename = nil, io = nil) opt = MAPPING_OPT.dup unless elename if definition = @registry.elename_schema_definition_from_class(obj.class) elename = definition.elename opt[:root_type_hint] = false end end elename = SOAP::Mapping.to_qname(elename) if elename soap = SOAP::Mapping.obj2soap(obj, @registry, elename, opt) if soap.elename.nil? or soap.elename == XSD::QName::EMPTY soap.elename = XSD::QName.new(nil, SOAP::Mapping.name2elename(obj.class.to_s)) end return soap end |