Class: Bandwidth::Bxml::NestableVerb
- Defined in:
- lib/bandwidth-sdk/models/bxml/nestable_verb.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#generate_xml ⇒ Node
Generate an XML element for the verb.
-
#initialize(tag, content = nil, nested_verbs = [], attributes = {}) ⇒ NestableVerb
constructor
Initializer.
Methods inherited from Verb
Constructor Details
#initialize(tag, content = nil, nested_verbs = [], attributes = {}) ⇒ NestableVerb
Initializer
11 12 13 14 15 16 |
# File 'lib/bandwidth-sdk/models/bxml/nestable_verb.rb', line 11 def initialize(tag, content = nil, nested_verbs = [], attributes = {}) @tag = tag @content = content @nested_verbs = Array(nested_verbs) @attributes = attributes end |
Instance Method Details
#generate_xml ⇒ Node
Generate an XML element for the verb
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/bandwidth-sdk/models/bxml/nestable_verb.rb', line 20 def generate_xml root = Ox::Element.new(@tag) if @content root << @content end if @nested_verbs.length > 0 @nested_verbs.each do |verb| root << verb.generate_xml end end if !@attributes.empty? && !@attribute_map.nil? @attributes.each do |key, value| if @attribute_map.include? key.to_sym root[@attribute_map[key.to_sym]] = value else raise NoMethodError.new("attribute '#{key}' is not a valid attribute for this verb") end end end root end |