Top Level Namespace
Defined Under Namespace
Modules: JAXB2Ruby
Constant Summary collapse
- UNSUPPORTED_TYPES =
[:ID, :IDREF, :boolean, "String", "Object"]
Instance Method Summary collapse
- #accessor_method(node) ⇒ Object
- #accessor_name(node) ⇒ Object
-
#namespace(ns) ⇒ Object
HappyMapper quirk: we need to return nil if there’s no namespace, otherwise the parent element’s namespace will be used in XPath searches.
- #namespace_map(klass) ⇒ Object
- #type_name(node) ⇒ Object
- #unsupported_type?(type) ⇒ Boolean
Instance Method Details
#accessor_method(node) ⇒ Object
1 2 3 4 5 6 7 8 9 |
# File 'lib/templates/util/happymapper.rb', line 1 def accessor_method(node) if node.array? "has_many" elsif node.type.to_s.include?("::") # Class with namespace? "has_one" else "element" end end |
#accessor_name(node) ⇒ Object
25 26 27 28 29 |
# File 'lib/templates/util/roxml.rb', line 25 def accessor_name(node) name = ":#{node.accessor}" name << "?" if node.type == :boolean name end |
#namespace(ns) ⇒ Object
HappyMapper quirk: we need to return nil if there’s no namespace, otherwise the parent element’s namespace will be used in XPath searches
13 14 15 |
# File 'lib/templates/util/happymapper.rb', line 13 def namespace(ns) ns.blank? ? "nil" : %|"#{ns.prefix}"| end |
#namespace_map(klass) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/templates/util/roxml.rb', line 7 def namespace_map(klass) ns = [klass.element].concat(klass.element.children).map { |e| e.namespace }.compact.uniq return unless ns.any? map = "xml_namespaces " map << ns.map { |e| sprintf('"%s" => "%s"', e.prefix, e) }.join(", ") end |
#type_name(node) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/templates/util/roxml.rb', line 15 def type_name(node) name = unsupported_type?(node.type) ? "" : node.type.dup # May be an attribute node if node.respond_to?(:array?) && node.array? name.prepend "[" name.concat "]" end name end |
#unsupported_type?(type) ⇒ Boolean
3 4 5 |
# File 'lib/templates/util/roxml.rb', line 3 def unsupported_type?(type) UNSUPPORTED_TYPES.include?(type) end |