Class: XmlPatch::Applicator

Inherits:
Object
  • Object
show all
Defined in:
lib/xml_patch/applicator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(diff_xml) ⇒ Applicator

Returns a new instance of Applicator.



8
9
10
# File 'lib/xml_patch/applicator.rb', line 8

def initialize(diff_xml)
  @diff_xml = diff_xml.dup.freeze
end

Instance Attribute Details

#diff_xmlObject (readonly)

Returns the value of attribute diff_xml.



6
7
8
# File 'lib/xml_patch/applicator.rb', line 6

def diff_xml
  @diff_xml
end

Instance Method Details

#to(target_xml) ⇒ Object



12
13
14
15
16
17
# File 'lib/xml_patch/applicator.rb', line 12

def to(target_xml)
  diff = XmlPatch::DiffBuilder.new.parse(diff_xml).diff_document
  target = XmlPatch::TargetDocument.new(target_xml)
  diff.apply_to(target)
  target.to_xml
end