Class: T2Server::XML::XPathCache
- Inherits:
-
Object
- Object
- T2Server::XML::XPathCache
- Includes:
- Singleton, Methods
- Defined in:
- lib/t2-server/xml/xpath_cache.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize ⇒ XPathCache
constructor
A new instance of XPathCache.
- #register_xpaths(xpaths) ⇒ Object
Methods included from Methods
#get_uris_from_doc, #xml_children, #xml_document, #xml_first_child, #xml_node_attribute, #xml_node_content, #xml_node_name, #xml_text_node, #xpath_attr, #xpath_compile, #xpath_find, #xpath_first
Constructor Details
#initialize ⇒ XPathCache
Returns a new instance of XPathCache.
41 42 43 44 |
# File 'lib/t2-server/xml/xpath_cache.rb', line 41 def initialize @cache = {} @xpaths = {} end |
Instance Method Details
#[](key) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/t2-server/xml/xpath_cache.rb', line 46 def [](key) return nil unless @xpaths.has_key? key return @cache[key] if @cache.has_key? key xpath = @xpaths[key] @cache[key] = xpath_compile(xpath) end |
#register_xpaths(xpaths) ⇒ Object
54 55 56 |
# File 'lib/t2-server/xml/xpath_cache.rb', line 54 def register_xpaths(xpaths) @xpaths.merge! xpaths end |