Class: Moxml::Entity::Restorer

Inherits:
Object
  • Object
show all
Defined in:
lib/moxml/entity/restorer.rb

Overview

Restores configured character entities into explicit Moxml::Entity::Reference nodes after a native tree has been parsed and wrapped — for adapters whose parser resolves entities during parsing (libxml, and the restore_entities option on rexml/oga).

Instance Method Summary collapse

Constructor Details

#initialize(doc) ⇒ Restorer

Returns a new instance of Restorer.



11
12
13
14
15
16
17
# File 'lib/moxml/entity/restorer.rb', line 11

def initialize(doc)
  @doc = doc
  @ctx = doc.context
  @registry = @ctx.entity_registry
  @config = @ctx.config
  @adapter = @ctx.config.adapter
end

Instance Method Details

#runObject



19
20
21
22
23
# File 'lib/moxml/entity/restorer.rb', line 19

def run
  return unless @registry && @doc.root

  walk(@doc.root)
end