Sha256: 13903437df11128747a1eb2e2a36a058f20bab76cbb205dea49ee54bd211c68c

Contents?: true

Size: 583 Bytes

Versions: 4

Compression:

Stored size: 583 Bytes

Contents

module Troy
  class XML
    # The XML content.
    #
    attr_reader :content

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

    def initialize(content, data)
      @content = content
      @data = data
    end

    def context
      @context ||= Context.new(data.merge(xml: xml)).extend(Helpers)
    end

    def xml
      @xml ||= Builder::XmlMarkup.new(indent: 2)
    end

    def to_xml
      @to_xml ||= begin
        xml.instruct!
        context.instance_eval(content)
        xml.target!
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
troy-0.0.35 lib/troy/xml.rb
troy-0.0.34 lib/troy/xml.rb
troy-0.0.33 lib/troy/xml.rb
troy-0.0.32 lib/troy/xml.rb