xml_schema_mapper 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
@@ -57,14 +57,18 @@ module XmlSchemaMapper
|
|
57
57
|
(klass_name + "Converter").safe_constantize
|
58
58
|
end
|
59
59
|
|
60
|
-
def mapper_class
|
61
|
-
mapper_class_name.constantize
|
60
|
+
def mapper_class(safe=false)
|
61
|
+
safe ? mapper_class_name.safe_constantize : mapper_class_name.constantize
|
62
62
|
end
|
63
63
|
|
64
64
|
def mapper_class_name
|
65
65
|
klass_name + "Mapper"
|
66
66
|
end
|
67
67
|
|
68
|
+
def klass
|
69
|
+
klass_name.safe_constantize
|
70
|
+
end
|
71
|
+
|
68
72
|
def klass_name
|
69
73
|
if type.name.nil?
|
70
74
|
name.underscore.camelize
|
@@ -1,13 +1,13 @@
|
|
1
1
|
module XmlSchemaMapper
|
2
2
|
class Parser
|
3
3
|
def initialize(klass)
|
4
|
-
@klass
|
4
|
+
@klass = klass
|
5
5
|
@module = resolve_module
|
6
6
|
end
|
7
7
|
|
8
8
|
def parse(xml)
|
9
9
|
instance = @klass.new
|
10
|
-
xml
|
10
|
+
xml = document(xml)
|
11
11
|
@klass.elements.each do |e|
|
12
12
|
if e.array?
|
13
13
|
write_array_element(e, instance, xml)
|
@@ -68,7 +68,13 @@ module XmlSchemaMapper
|
|
68
68
|
private
|
69
69
|
|
70
70
|
def resolve_element_parser(element)
|
71
|
-
|
71
|
+
element_class_in_current_namespace(element) || element.mapper_class(true) || element.klass || raise_class_not_found(element)
|
72
|
+
end
|
73
|
+
|
74
|
+
def element_class_in_current_namespace(element) # prevent top-level constant referencing
|
75
|
+
if @klass.const_defined?(element.klass_name, false)
|
76
|
+
@klass.const_get(element.klass_name, false)
|
77
|
+
end
|
72
78
|
end
|
73
79
|
|
74
80
|
def parsers_for_resolve(element)
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: xml_schema_mapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.12
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Anton Sozontov
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-07-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -187,3 +187,4 @@ test_files:
|
|
187
187
|
- spec/spec_helper.rb
|
188
188
|
- spec/visitor_spec.rb
|
189
189
|
- spec/xml_schema_mapper_spec.rb
|
190
|
+
has_rdoc:
|