Class: Lorax::DeleteDelta

Inherits:
Delta
  • Object
show all
Defined in:
lib/lorax/delta/delete_delta.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Delta

#inspect

Constructor Details

#initialize(node) ⇒ DeleteDelta

Returns a new instance of DeleteDelta.



5
6
7
# File 'lib/lorax/delta/delete_delta.rb', line 5

def initialize(node)
  @node = node
end

Instance Attribute Details

#nodeObject

Returns the value of attribute node.



3
4
5
# File 'lib/lorax/delta/delete_delta.rb', line 3

def node
  @node
end

Instance Method Details

#apply!(document) ⇒ Object

Raises:



9
10
11
12
13
# File 'lib/lorax/delta/delete_delta.rb', line 9

def apply!(document)
  target = document.at_xpath(node.path)
  raise NodeNotFoundError, xpath unless target
  target.unlink
end

#descriptorObject



15
16
17
# File 'lib/lorax/delta/delete_delta.rb', line 15

def descriptor
  [:delete, {:xpath => node.path, :content => node.to_s}]
end