Module: XPain::CustomNodes
- Included in:
- Builder
- Defined in:
- lib/xpain/custom_nodes.rb
Instance Method Summary collapse
- #attribute(name, opts = {}) ⇒ Object
- #define_complex_type(name, opts = {}, &block) ⇒ Object
- #define_inline_complex_type(collection_type = "simpleContent", &block) ⇒ Object
- #document(text) ⇒ Object
- #element(name, opts = {}, &block) ⇒ Object
- #elements(list, opts = {}) ⇒ Object
- #include(name) ⇒ Object
- #schema(opts = {}, &block) ⇒ Object
Instance Method Details
#attribute(name, opts = {}) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/xpain/custom_nodes.rb', line 39 def attribute(name, opts = {}) if name.is_a?(String) opts.merge!({:name => name}) else opts.merge!(name) end create_custom_node("attribute", opts) end |
#define_complex_type(name, opts = {}, &block) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/xpain/custom_nodes.rb', line 11 def define_complex_type(name, opts = {}, &block) node_type = opts.delete(:contains) || "simpleContent" create_custom_node("complexType", :name => name) do create_custom_node(node_type, opts, &block) end end |
#define_inline_complex_type(collection_type = "simpleContent", &block) ⇒ Object
19 20 21 22 23 |
# File 'lib/xpain/custom_nodes.rb', line 19 def define_inline_complex_type(collection_type = "simpleContent", &block) create_custom_node("complexType") do create_custom_node(collection_type, &block) end end |
#document(text) ⇒ Object
55 56 57 58 59 |
# File 'lib/xpain/custom_nodes.rb', line 55 def document(text) create_custom_node('annotation') do |xsd| xsd.documentation text end end |
#element(name, opts = {}, &block) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/xpain/custom_nodes.rb', line 25 def element(name, opts = {}, &block) collection_type = opts.delete(:contains) || "all" if block_given? if collection_type == 'none' create_custom_node("element", opts.merge!({:name => name}), &block) else define_inline_complex_type(collection_type, &block) end else create_custom_node("element", opts.merge!({:name => name})) end end |
#elements(list, opts = {}) ⇒ Object
49 50 51 52 53 |
# File 'lib/xpain/custom_nodes.rb', line 49 def elements(list, opts = {}) list.each do |li| element(li, opts) end end |
#include(name) ⇒ Object
7 8 9 |
# File 'lib/xpain/custom_nodes.rb', line 7 def include(name) create_custom_node("include", {"schemaLocation" => name}) end |
#schema(opts = {}, &block) ⇒ Object
3 4 5 |
# File 'lib/xpain/custom_nodes.rb', line 3 def schema(opts = {}, &block) create_custom_node("xsd:schema", {"xmlns:xsd" => "http://www.w3.org/2001/XMLSchema"}, &block) end |