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

Returns a new instance of ChangeNode.



113
114
115
116
117
# File 'lib/resync/xml.rb', line 113

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.



120
121
122
# File 'lib/resync/xml.rb', line 120

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.



125
126
127
# File 'lib/resync/xml.rb', line 125

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