Class: Resync::XML::ChangeNode

Inherits:
XML::Mapping::SingleAttributeNode
  • Object
show all
Defined in:
lib/resync/xml.rb

Overview

Maps Resync::Types::Change values.

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ ChangeNode



110
111
112
113
114
# File 'lib/resync/xml.rb', line 110

def initialize(*args)
  path, *args = super(*args)
  @path = ::XML::XXPath.new(path)
  args
end

Instance Method Details

#extract_attr_value(xml) ⇒ Object

Implements ::XML::Mapping::SingleAttributeNode#extract_attr_value.



117
118
119
# File 'lib/resync/xml.rb', line 117

def extract_attr_value(xml)
  Resync::Types::Change.parse(default_when_xpath_err { @path.first(xml).text })
end

#set_attr_value(xml, value) ⇒ Object

Implements ::XML::Mapping::SingleAttributeNode#set_attr_value.



122
123
124
# File 'lib/resync/xml.rb', line 122

def set_attr_value(xml, value)
  @path.first(xml, ensure_created: true).text = value.to_s
end