lib/bandwidth-sdk/models/bxml/verb.rb in bandwidth-sdk-11.0.0.pre.beta.1.1 vs lib/bandwidth-sdk/models/bxml/verb.rb in bandwidth-sdk-11.0.0.pre.beta.2.0
- old
+ new
@@ -1,19 +1,18 @@
require 'ox'
module Bandwidth
module Bxml
- module Verb
+ class Verb
# Initializer
# @param tag [String] Name of the XML element.
# @param content [String] XML element content. Defaults to nil.
# @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
def initialize(tag, content = nil, attributes = {})
@tag = tag
@content = content
@attributes = attributes
- @attribute_map = []
end
# Set XML attributes for the verb
# @param attributes [Hash] The attributes to add to the element.
def set_attributes(attributes)
@@ -26,26 +25,26 @@
root = Ox::Element.new(@tag)
if @content
root << @content
end
- if !@attributes.empty?
+ 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
- return root
+ root
end
# Return BXML representaion of this element
# @return [String] The XML element in string format.
def to_bxml
- return Ox.dump(generate_xml)
+ Ox.dump(generate_xml)
end
end
end
end