Class: ApiBuilder::StringWithName

Inherits:
String
  • Object
show all
Defined in:
lib/api_builder/with_name.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, value) ⇒ StringWithName

Returns a new instance of StringWithName.



31
32
33
34
# File 'lib/api_builder/with_name.rb', line 31

def initialize(name, value)
  @name = name
  super value.to_s
end

Instance Method Details

#to_xml(options = {}) ⇒ Object



36
37
38
39
40
41
42
43
44
# File 'lib/api_builder/with_name.rb', line 36

def to_xml(options = {})
  if options[:builder]
    xml = options[:builder]
  else
    xml = Builder::XmlMarkup.new
    xml.instruct!
  end
  xml.tag! name, to_s
end