class Troy::XML

Attributes

content[R]

The XML content.

data[R]

The data that must be rendered within the Troy::Context object.

Public Class Methods

new(content, data) click to toggle source
# File lib/troy/xml.rb, line 14
def initialize(content, data)
  @content = content
  @data = data
end

Public Instance Methods

context() click to toggle source
# File lib/troy/xml.rb, line 19
def context
  @context ||= Context.new(data.merge(xml: xml)).extend(Helpers)
end
to_xml() click to toggle source
# File lib/troy/xml.rb, line 27
def to_xml
  @to_xml ||= begin
    xml.instruct!
    context.instance_eval(content)
    xml.target!
  end
end
xml() click to toggle source
# File lib/troy/xml.rb, line 23
def xml
  @xml ||= Builder::XmlMarkup.new(indent: 2)
end