Class: LolSoap::Builder
- Inherits:
-
Object
- Object
- LolSoap::Builder
- Defined in:
- lib/lolsoap/builder.rb
Overview
Used to build XML, with namespaces automatically added.
Constant Summary collapse
- RESERVED_METHODS =
%w(object_id respond_to_missing? inspect === to_s)
Instance Method Summary collapse
-
#[](prefix) ⇒ Object
Specify a namespace prefix explicitly.
- #__attribute__(name, value) ⇒ Object
- #__content__(value) ⇒ Object
-
#__node__ ⇒ Object
Node accessor.
-
#__tag__(name, *args, &block) ⇒ Object
Add a tag manually, rather than through method_missing.
-
#__type__ ⇒ Object
Type accessor.
-
#initialize(node, type = WSDL::NullType.new) ⇒ Builder
constructor
A new instance of Builder.
- #pretty_print(pp) ⇒ Object
- #respond_to?(name) ⇒ Boolean
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object (private)
alias method_missing __tag__
122 123 124 125 126 127 128 |
# File 'lib/lolsoap/builder.rb', line 122 def method_missing(name, *args, &block) if @type.has_attribute?(name.to_s) __attribute__(name, *args) else __tag__(name, *args, &block) end end |
Instance Method Details
#[](prefix) ⇒ Object
Specify a namespace prefix explicitly
105 106 107 |
# File 'lib/lolsoap/builder.rb', line 105 def [](prefix) Prefix.new(self, prefix) end |
#__attribute__(name, value) ⇒ Object
60 61 62 |
# File 'lib/lolsoap/builder.rb', line 60 def __attribute__(name, value) @node[name.to_s] = value.to_s end |
#__content__(value) ⇒ Object
64 65 66 |
# File 'lib/lolsoap/builder.rb', line 64 def __content__(value) @node.content = value end |
#__node__ ⇒ Object
Node accessor. Named to prevent method_missing conflict.
95 96 97 |
# File 'lib/lolsoap/builder.rb', line 95 def __node__ @node end |
#__tag__(name, *args, &block) ⇒ Object
Add a tag manually, rather than through method_missing. This is so you can still add tags for the very small number of tags that are also existing methods.
56 57 58 |
# File 'lib/lolsoap/builder.rb', line 56 def __tag__(name, *args, &block) __prefixed_tag__(@type.element_prefix(name.to_s), @type.sub_type(name.to_s), name, *args, &block) end |
#__type__ ⇒ Object
Type accessor. Named to prevent method_missing conflict.
100 101 102 |
# File 'lib/lolsoap/builder.rb', line 100 def __type__ @type end |
#pretty_print(pp) ⇒ Object
113 114 115 116 117 |
# File 'lib/lolsoap/builder.rb', line 113 def pretty_print(pp) pp.group(2, "#(LolSoap::Builder #{sprintf("0x%x", object_id)} {", "})") do pp.pp @node end end |
#respond_to?(name) ⇒ Boolean
109 110 111 |
# File 'lib/lolsoap/builder.rb', line 109 def respond_to?(name) true end |