Sha256: 48813d7a5facfb790ca89194b4f891065fd84c39987f4958d88230229d84d808
Contents?: true
Size: 1.36 KB
Versions: 7
Compression:
Stored size: 1.36 KB
Contents
require 'ox' module Bandwidth module Bxml class NestableVerb < Bandwidth::Bxml::Verb # Initializer # @param tag [String] Name of the XML element. # @param content [String] XML element content. Defaults to nil. # @param nested_verbs [Verb] or [Array<Verb>] XML element children. Defaults to an empty array. # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash. def initialize(tag, content = nil, nested_verbs = [], attributes = {}) @tag = tag @content = content @nested_verbs = Array(nested_verbs) @attributes = attributes end # Generate an XML element for the verb # @return [Node] The XML element. 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 end end end
Version data entries
7 entries across 7 versions & 1 rubygems