Module: Canon::XmlBackend
- Defined in:
- lib/canon/xml_backend.rb
Overview
Centralized XML backend detection for Canon.
Canon supports two XML backends:
-
:nokogiri — MRI with Nokogiri installed (default, existing code path)
-
:moxml — Opal runtime or MRI without Nokogiri (uses Oga via moxml)
The active backend is determined once at load time and cached. All XML-related code should check ‘Canon::XmlBackend.moxml?` or `Canon::XmlBackend.nokogiri?` to select the appropriate code path.
This module intentionally does NOT wrap Nokogiri through moxml. Each backend path is independent — the Nokogiri path is the existing battle-tested code; the moxml path is a parallel implementation for environments where Nokogiri is unavailable.
Class Method Summary collapse
Class Method Details
.active ⇒ Object
20 21 22 |
# File 'lib/canon/xml_backend.rb', line 20 def active @active ||= detect end |
.moxml? ⇒ Boolean
28 29 30 |
# File 'lib/canon/xml_backend.rb', line 28 def moxml? active == :moxml end |
.nokogiri? ⇒ Boolean
24 25 26 |
# File 'lib/canon/xml_backend.rb', line 24 def nokogiri? active == :nokogiri end |
.reset! ⇒ Object
32 33 34 |
# File 'lib/canon/xml_backend.rb', line 32 def reset! @active = nil end |